本文整理汇总了PHP中FrmField::is_field_with_multiple_values方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmField::is_field_with_multiple_values方法的具体用法?PHP FrmField::is_field_with_multiple_values怎么用?PHP FrmField::is_field_with_multiple_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmField
的用法示例。
在下文中一共展示了FrmField::is_field_with_multiple_values方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_field_value_for_new_entry
/**
* Set the value for each field
* This function is used when the form is first loaded and on all page turns *for a new entry*
*
* @since 2.0.13
*
* @param object $field - this is passed by reference since it is an object
* @param boolean $reset
* @param array $args
* @return string|array $new_value
*/
private static function get_field_value_for_new_entry($field, $reset, $args)
{
//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
$return_array = FrmField::is_field_with_multiple_values($field);
// Do any shortcodes in default value and allow customization of default value
$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
// Calls FrmProFieldsHelper::get_default_value
$new_value = $field->default_value;
if (!$reset && self::value_is_posted($field, $args)) {
self::get_posted_value($field, $new_value, $args);
} else {
if (FrmField::is_option_true($field, 'clear_on_focus')) {
// If clear on focus is selected, the value should be blank (unless it was posted, of course)
// TODO: move to Pro
if ('address' == $field->type && isset($new_value['country'])) {
$new_value = array('country' => $new_value['country']);
} else {
$new_value = '';
}
}
}
if (!is_array($new_value)) {
$new_value = str_replace('"', '"', $new_value);
}
return $new_value;
}
示例2: get_field_value_for_new_entry
/**
* Set the value for each field
* This function is used when the form is first loaded and on all page turns *for a new entry*
*
* @since 2.0.13
*
* @param object $field - this is passed by reference since it is an object
* @param boolean $reset
* @return string|array $new_value
*/
private static function get_field_value_for_new_entry($field, $reset)
{
//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
$return_array = FrmField::is_field_with_multiple_values($field);
// Do any shortcodes in default value and allow customization of default value
$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
// Calls FrmProFieldsHelper::get_default_value
$new_value = $field->default_value;
if (!$reset && $_POST && isset($_POST['item_meta'][$field->id])) {
// If value was posted, get it
$new_value = stripslashes_deep($_POST['item_meta'][$field->id]);
} else {
if (FrmField::is_option_true($field, 'clear_on_focus')) {
// If clear on focus is selected, the value should be blank (unless it was posted, of course)
$new_value = '';
}
}
if (!is_array($new_value)) {
$new_value = str_replace('"', '"', $new_value);
}
return $new_value;
}
示例3: is_field_with_multiple_values
public static function is_field_with_multiple_values($field)
{
_deprecated_function(__FUNCTION__, '2.0.9', 'FrmField::is_field_with_multiple_values');
return FrmField::is_field_with_multiple_values($field);
}
示例4: prepare_where_args
/**
* Called by the filter_where function
*/
private static function prepare_where_args(&$args, $where_field, $entry_ids)
{
if ($args['where_val'] == 'NOW') {
$date_format = 'Y-m-d';
if ($where_field->type == 'time') {
$time_format = isset($where_field->field_options['clock']) ? $where_field->field_options['clock'] : 12;
$date_format = $time_format == 12 ? 'h:i A' : 'H:i';
}
$args['where_val'] = self::get_date($date_format);
unset($date_format);
}
if ($where_field->type == 'date' && !empty($args['where_val'])) {
$args['where_val'] = date('Y-m-d', strtotime($args['where_val']));
} else {
if ($args['where_is'] == '=' && $args['where_val'] != '' && FrmField::is_field_with_multiple_values($where_field)) {
if ($where_field->type != 'data' || $where_field->field_options['data_type'] != 'checkbox' || is_numeric($args['where_val'])) {
// leave $args['where_is'] the same if this is a data from entries checkbox with a numeric value
$args['where_is'] = 'LIKE';
}
}
}
$args['temp_where_is'] = str_replace(array('!', 'not '), '', $args['where_is']);
//get values that aren't blank and then remove them from entry list
if ($args['where_val'] == '' && $args['temp_where_is'] == '=') {
$args['temp_where_is'] = '!=';
}
if (in_array($args['where_is'], array('LIKE', 'not LIKE'))) {
//add extra slashes to match values that are escaped in the database
$args['where_val_esc'] = addslashes($args['where_val']);
} else {
if (!strpos($args['where_is'], 'in') && !is_numeric($args['where_val'])) {
$args['where_val_esc'] = $args['where_val'];
}
}
$filter_args = $args;
$filter_args['entry_ids'] = $entry_ids;
$args['where_val'] = apply_filters('frm_filter_where_val', $args['where_val'], $filter_args);
self::prepare_dfe_text($args, $where_field);
}
示例5: get_field_stats
public static function get_field_stats($id, $type = 'total', $user_id = false, $value = false, $round = 100, $limit = '', $atts = array(), $drafts = false)
{
global $wpdb, $frm_post_ids;
$field = FrmField::getOne($id);
if (!$field) {
return 0;
}
$id = $field->id;
if (isset($atts['thousands_sep']) && $atts['thousands_sep']) {
$thousands_sep = $atts['thousands_sep'];
unset($atts['thousands_sep']);
$round = $round == 100 ? 2 : $round;
}
$where = array();
if ($value) {
$slash_val = strpos($value, '\\') === false ? addslashes($value) : $value;
if (FrmField::is_field_with_multiple_values($field)) {
$where[] = array('or' => 1, 'meta_value like' => $value, 'meta_value like ' => $slash_val);
//add extra slashes to match values that are escaped in the database
} else {
//$where_value = $wpdb->prepare(" meta_value = %s", addcslashes( $slash_val, '_%' ) );
$where[] = array('or' => 1, 'meta_value' => $value, 'meta_value ' => addcslashes($slash_val, '_%'));
}
unset($slash_val);
}
//if(!$frm_post_ids)
$frm_post_ids = array();
$post_ids = array();
if (isset($frm_post_ids[$id])) {
$form_posts = $frm_post_ids[$id];
} else {
$where_post = array('form_id' => $field->form_id, 'post_id >' => 1);
if ($drafts != 'both') {
$where_post['is_draft'] = $drafts;
}
if ($user_id) {
$where_post['user_id'] = $user_id;
}
$form_posts = FrmDb::get_results('frm_items', $where_post, 'id,post_id');
$frm_post_ids[$id] = $form_posts;
}
foreach ((array) $form_posts as $form_post) {
$post_ids[$form_post->id] = $form_post->post_id;
}
if ($value) {
$atts[$id] = $value;
}
if (!empty($atts)) {
$entry_ids = array();
if (isset($atts['entry_id']) && $atts['entry_id'] && is_numeric($atts['entry_id'])) {
$entry_ids[] = $atts['entry_id'];
}
$after_where = false;
foreach ($atts as $orig_f => $val) {
// Accommodate for times when users are in Visual tab
$val = str_replace(array('>', '<'), array('>', '<'), $val);
// If first character is a quote, but the last character is not a quote
if (strpos($val, '"') === 0 && substr($val, -1) != '"' || strpos($val, "'") === 0 && substr($val, -1) != "'") {
//parse atts back together if they were broken at spaces
$next_val = array('char' => substr($val, 0, 1), 'val' => $val);
continue;
// If we don't have a previous value that needs to be parsed back together
} else {
if (!isset($next_val)) {
$temp = FrmAppHelper::replace_quotes($val);
foreach (array('"', "'") as $q) {
// Check if <" or >" exists in string and string does not end with ".
if (substr($temp, -1) != $q && (strpos($temp, '<' . $q) || strpos($temp, '>' . $q))) {
$next_val = array('char' => $q, 'val' => $val);
$cont = true;
}
unset($q);
}
unset($temp);
if (isset($cont)) {
unset($cont);
continue;
}
}
}
// If we have a previous value saved that needs to be parsed back together (due to WordPress pullling it apart)
if (isset($next_val)) {
if (substr(FrmAppHelper::replace_quotes($val), -1) == $next_val['char']) {
$val = $next_val['val'] . ' ' . $val;
unset($next_val);
} else {
$next_val['val'] .= ' ' . $val;
continue;
}
}
$entry_ids = self::get_field_matches(compact('entry_ids', 'orig_f', 'val', 'id', 'atts', 'field', 'form_posts', 'after_where', 'drafts'));
$after_where = true;
}
if (empty($entry_ids)) {
if ($type == 'star') {
$stat = '';
ob_start();
include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/star_disabled.php';
$contents = ob_get_contents();
ob_end_clean();
//.........这里部分代码省略.........
示例6: clean_inputs
/**
* Strip slashes and get rid of multi-dimensional arrays in inputs
*
* @since 2.0
*
* @param array $inputs
* @param object $field
* @param array $args
* @return array $inputs - cleaned inputs array
*/
public static function clean_inputs(&$inputs, $field, $args, $x_entries = array())
{
if (!$inputs) {
return false;
}
//Break out any inner arrays (for checkbox or multi-select fields) and add them to the end of the $inputs array
if (!$args['x_axis'] && FrmField::is_field_with_multiple_values($field)) {
$count = 0;
foreach ($inputs as $k => $i) {
$i = maybe_unserialize($i);
if (!is_array($i)) {
unset($k, $i);
continue;
}
unset($inputs[$k]);
$count++;
foreach ($i as $i_key => $item) {
// If this is an "other" option, keep key
if (strpos($i_key, 'other') !== false) {
$inputs[] = $i_key;
} else {
$inputs[] = $item;
}
unset($item, $i_key);
}
unset($k, $i);
}
unset($count);
}
if ($x_entries) {
// Get rid of inputs if there is no match in x_inputs
foreach ($inputs as $key => $input) {
if (!in_array($input['item_id'], $x_entries)) {
unset($inputs[$key]);
}
unset($key, $input);
}
}
//Strip slashes from inputs
$inputs = stripslashes_deep($inputs);
return $inputs;
}
示例7: setup_new_vars
public static function setup_new_vars($fields, $form = '', $reset = false)
{
global $frm_vars;
$values = array();
foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
$values[$var] = FrmAppHelper::get_post_param($var, $default);
}
$values['fields'] = array();
if (empty($fields)) {
return apply_filters('frm_setup_new_entry', $values);
}
foreach ((array) $fields as $field) {
$default = $field->default_value;
$posted_val = false;
$new_value = $default;
if (!$reset && $_POST && isset($_POST['item_meta'][$field->id]) && $_POST['item_meta'][$field->id] != '') {
$new_value = stripslashes_deep($_POST['item_meta'][$field->id]);
$posted_val = true;
} else {
if (FrmField::is_option_true($field, 'clear_on_focus')) {
$new_value = '';
}
}
$is_default = $new_value == $default ? true : false;
//If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
$return_array = FrmField::is_field_with_multiple_values($field);
$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
if (!is_array($new_value)) {
if ($is_default) {
$new_value = $field->default_value;
} else {
if (!$posted_val) {
$new_value = apply_filters('frm_filter_default_value', $new_value, $field);
}
}
$new_value = str_replace('"', '"', $new_value);
}
unset($is_default, $posted_val);
$field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
$opt_defaults['required_indicator'] = '';
$opt_defaults['original_type'] = $field->type;
foreach ($opt_defaults as $opt => $default_opt) {
$field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
unset($opt, $default_opt);
}
unset($opt_defaults);
if ($field_array['custom_html'] == '') {
$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
}
$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
$field_array = array_merge($field->field_options, $field_array);
$values['fields'][] = $field_array;
if (!$form || !isset($form->id)) {
$form = FrmForm::getOne($field->form_id);
}
}
$form->options = maybe_unserialize($form->options);
if (is_array($form->options)) {
foreach ($form->options as $opt => $value) {
$values[$opt] = FrmAppHelper::get_post_param($opt, $value);
unset($opt, $value);
}
}
$form_defaults = FrmFormsHelper::get_default_opts();
$frm_settings = FrmAppHelper::get_settings();
$form_defaults['custom_style'] = $frm_settings->load_style != 'none';
$values = array_merge($form_defaults, $values);
return apply_filters('frm_setup_new_entry', $values);
}