本文整理汇总了PHP中FrmAppHelper::replace_quotes方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmAppHelper::replace_quotes方法的具体用法?PHP FrmAppHelper::replace_quotes怎么用?PHP FrmAppHelper::replace_quotes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmAppHelper
的用法示例。
在下文中一共展示了FrmAppHelper::replace_quotes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_field_matches
public static function get_field_matches($args)
{
extract($args);
$f = $orig_f;
$where_is = '=';
//If using <, >, or != and $f is NOT a field ID
if ($f < 20 and !is_numeric($val)) {
// >, <, <=, >= TODO: %, !%
$orig_val = $val;
$lpos = strpos($val, '<');
$gpos = strpos($val, '>');
$not_pos = strpos($val, '!=');
if ($not_pos !== false) {
//If string contains !=
$where_is = '!=';
$str = explode($where_is, $orig_val);
$f = $str[0];
$val = $str[1];
if (empty($entry_ids) && $after_where == 0) {
//If entry IDs have not been set by a previous $atts
global $wpdb;
$query = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $field->form_id);
//By default, don't get drafts
if ($drafts != 'both') {
$query .= $wpdb->prepare(" AND is_draft=%d", $drafts);
}
$entry_ids = $wpdb->get_col($query);
unset($query);
}
$val = FrmAppHelper::replace_quotes($val);
$val = trim(trim($val, "'"), '"');
} else {
if ($lpos !== false || $gpos !== false) {
//If string contains greater than or less than
$where_is = ($gpos !== false and $lpos !== false and $lpos > $gpos or $lpos === false) ? '>' : '<';
$str = explode($where_is, $orig_val);
if (count($str) == 2) {
$f = $str[0];
$val = $str[1];
} else {
if (count($str) == 3) {
//3 parts assumes a structure like '-1 month'<255<'1 month'
$val = str_replace($str[0] . $where_is, '', $orig_val);
$entry_ids = self::get_field_matches(compact('entry_ids', 'orig_f', 'val', 'id', 'atts', 'field', 'form_posts', 'after_where', 'drafts'));
$after_where = true;
$f = $str[1];
$val = $str[0];
$where_is = $where_is == '<' ? '>' : '<';
}
}
if (strpos($val, '=') === 0) {
$where_is .= '=';
$val = substr($val, 1);
}
$val = FrmAppHelper::replace_quotes($val);
$val = trim(trim($val, "'"), '"');
}
}
}
if (!is_numeric($f)) {
if (in_array($f, array('created_at', 'updated_at'))) {
global $wpdb;
$query = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_items WHERE {$f} {$where_is} %s AND form_id = %d", $val, $field->form_id);
if ($after_where) {
if (!$entry_ids) {
return array();
}
$query .= ' AND id in (' . implode(',', $entry_ids) . ')';
}
$entry_ids = $wpdb->get_col($query);
return $entry_ids;
} else {
//check for field keys
$frm_field = new FrmField();
$this_field = $frm_field->getOne($f);
if ($this_field) {
$f = $this_field->id;
} else {
//If no field ID
return $entry_ids;
}
unset($this_field);
}
}
unset($orig_f);
$where_atts = apply_filters('frm_stats_where', array('where_is' => $where_is, 'where_val' => $val), array('id' => $id, 'atts' => $atts));
$val = $where_atts['where_val'];
$where_is = $where_atts['where_is'];
unset($where_atts);
$entry_ids = FrmProAppHelper::filter_where($entry_ids, array('where_opt' => $f, 'where_is' => $where_is, 'where_val' => $val, 'form_id' => $field->form_id, 'form_posts' => $form_posts, 'after_where' => $after_where, 'drafts' => $drafts));
unset($f);
unset($val);
return $entry_ids;
}
示例2: get_field_matches
public static function get_field_matches($args)
{
extract($args);
$f = $orig_f;
$where_is = '=';
//If using <, >, <=, >=, or != TODO: %, !%.
//Note: $f will be numeric if using <, >, <=, >=, != OR if using x=val, but the code in the if/else statement will not actually do anything to x=val.
if (is_numeric($f)) {
//Note: $f will count up for certain atts
$orig_val = $val;
$lpos = strpos($val, '<');
$gpos = strpos($val, '>');
$not_pos = strpos($val, '!=');
$dash_pos = strpos($val, '-');
if ($not_pos !== false) {
//If string contains !=
//If entry IDs have not been set by a previous $atts
if (empty($entry_ids) && $after_where == 0) {
$query = array('form_id' => $field->form_id);
//By default, don't get drafts
if ($drafts != 'both') {
$query['is_draft'] = $drafts;
}
$entry_ids = FrmDb::get_col('frm_items', $query);
unset($query);
}
$where_is = '!=';
$str = explode($where_is, $orig_val);
$f = $str[0];
$val = $str[1];
} else {
if ($lpos !== false || $gpos !== false) {
//If string contains greater than or less than
$where_is = $gpos !== false && $lpos !== false && $lpos > $gpos || $lpos === false ? '>' : '<';
$str = explode($where_is, $orig_val);
if (count($str) == 2) {
$f = $str[0];
$val = $str[1];
} else {
if (count($str) == 3) {
//3 parts assumes a structure like '-1 month'<255<'1 month'
$val = str_replace($str[0] . $where_is, '', $orig_val);
$entry_ids = self::get_field_matches(compact('entry_ids', 'orig_f', 'val', 'id', 'atts', 'field', 'form_posts', 'after_where', 'drafts'));
$after_where = true;
$f = $str[1];
$val = $str[0];
$where_is = $where_is == '<' ? '>' : '<';
}
}
if (strpos($val, '=') === 0) {
$where_is .= '=';
$val = substr($val, 1);
}
// If field key contains a dash, then it won't be put in as $f automatically (WordPress quirk maybe?)
// Use $f < 5 to decrease the likelihood of this section being used when $f is a field ID (like x=val)
} else {
if ($dash_pos !== false && strpos($val, '=') !== false && $f < 5) {
$str = explode($where_is, $orig_val);
$f = $str[0];
$val = $str[1];
}
}
}
}
// If this function has looped through at least once, and there aren't any entry IDs
if ($after_where && !$entry_ids) {
return array();
}
//If using field key
if (!is_numeric($f)) {
if (in_array($f, array('created_at', 'updated_at'))) {
global $wpdb;
$val = FrmAppHelper::replace_quotes($val);
$val = str_replace(array('"', "'"), "", $val);
$val = date('Y-m-d', strtotime($val));
$query = array('form_id' => $field->form_id, $f . FrmDb::append_where_is($where_is) => $val);
// Entry IDs may be set even if after_where isn't true
if ($entry_ids) {
$query['id'] = $entry_ids;
}
$entry_ids = FrmDb::get_col('frm_items', $query);
return $entry_ids;
} else {
//check for field keys
$this_field = FrmField::getOne($f);
if ($this_field) {
$f = $this_field->id;
} else {
//If no field ID
return $entry_ids;
}
unset($this_field);
}
}
unset($orig_f);
//Prepare val
$val = FrmAppHelper::replace_quotes($val);
$val = trim(trim($val, "'"), '"');
$where_atts = apply_filters('frm_stats_where', array('where_is' => $where_is, 'where_val' => $val), array('id' => $id, 'atts' => $atts));
$val = $where_atts['where_val'];
//.........这里部分代码省略.........
示例3: graph_shortcode
public static function graph_shortcode($atts)
{
$defaults = array('id' => false, 'id2' => false, 'id3' => false, 'id4' => false, 'ids' => array(), 'colors' => '', 'grid_color' => '#CCC', 'is3d' => false, 'height' => 400, 'width' => 400, 'truncate_label' => 7, 'bg_color' => '#FFFFFF', 'truncate' => 40, 'response_count' => 10, 'user_id' => false, 'entry_id' => false, 'title' => '', 'type' => 'default', 'x_axis' => false, 'data_type' => 'count', 'limit' => '', 'show_key' => false, 'min' => '', 'max' => '', 'y_title' => '', 'x_title' => '', 'include_zero' => false, 'field' => false, 'title_size' => '', 'title_font' => '', 'tooltip_label' => '', 'start_date' => '', 'end_date' => '', 'x_start' => '', 'x_end' => '', 'group_by' => '', 'x_order' => 'default', 'atts' => false);
// TODO: Remove limit from docs, add x_order='desc' and x_order='field_options'
// Remove id from docs. Just use ids to simplify.
// Remove either x start or start_date from docs
// Remove either x_end or end_date from docs
// Make sure x_order is set up to work with abc
// If no id, stop now
if (!$atts || !$atts['id']) {
echo __('You must include a field id or key in your graph shortcode.', 'formidable');
return;
}
if (isset($atts['type']) && $atts['type'] == 'geo') {
$defaults['truncate_label'] = 100;
$defaults['width'] = 600;
}
if (isset($atts['include_js'])) {
unset($atts['include_js']);
}
// Set up array for filtering fields
// TODO: Ask about simpler way
$temp_atts = $atts;
foreach ($defaults as $unset => $val) {
unset($temp_atts[$unset], $unset, $val);
}
foreach ($temp_atts as $unset => $val) {
unset($atts[$unset]);
$atts['atts'][$unset] = $val;
unset($unset, $val);
}
// User's values should override default values
$atts = array_merge($defaults, $atts);
global $wpdb;
// Reverse compatibility for id2, id3, and id4
if (!$atts['ids'] && ($atts['id2'] || $atts['id3'] || $atts['id4'])) {
_deprecated_argument(__FUNCTION__, '1.07.05', __('id2, id3, and id4 are deprecated. Please use ids instead.', 'formidable'));
$atts['ids'] = array($atts['id2'], $atts['id3'], $atts['id4']);
$atts['ids'] = implode(',', $atts['ids']);
unset($atts['id2'], $atts['id3'], $atts['id4']);
}
//x_start and start_date do the same thing
// Reverse compatibility for x_start
if ($atts['start_date'] || $atts['x_start']) {
if ($atts['x_start']) {
$atts['start_date'] = $atts['x_start'];
unset($atts['x_start']);
}
$atts['start_date'] = FrmAppHelper::replace_quotes($atts['start_date']);
}
//x_end and end_date do the same thing
// Reverse compatibility for x_end
if ($atts['end_date'] || $atts['x_end']) {
if ($atts['x_end']) {
$atts['end_date'] = $atts['x_end'];
unset($atts['x_end']);
}
$atts['end_date'] = FrmAppHelper::replace_quotes($atts['end_date']);
}
// Reverse compatibility for x_order=0
if (!$atts['x_order']) {
$atts['x_order'] = 'field_opts';
}
// If limit is set, get only the top results
if ($atts['limit']) {
$atts['x_order'] = 'desc';
}
$atts['user_id'] = FrmAppHelper::get_user_id_param($atts['user_id']);
if ($atts['entry_id']) {
$atts['entry_id'] = explode(',', $atts['entry_id']);
//make sure all values are numeric
//TODO: Make this work with entry keys
$atts['entry_id'] = array_filter($atts['entry_id'], 'is_numeric');
if (empty($atts['entry_id'])) {
// don't continue if there are no entry ids
return;
}
$atts['entry_id'] = implode(',', $atts['entry_id']);
}
// Switch to entry_ids for easier reference
$atts['entry_ids'] = $atts['entry_id'];
unset($atts['entry_id']);
//Convert $tooltip_label to array
if ($atts['tooltip_label']) {
$atts['tooltip_label'] = explode(',', $atts['tooltip_label']);
}
// This will only be an object when coming from show()
if (is_object($atts['field'])) {
$fields = array($atts['field']);
// If creating multiple graphs with one shortcode
} else {
$atts['id'] = explode(',', $atts['id']);
foreach ($atts['id'] as $key => $id) {
//If using field keys, retrieve the field IDs
if (!is_numeric($id)) {
$atts['id'][$key] = FrmDb::get_var($wpdb->prefix . 'frm_fields', array('field_key' => $id));
}
unset($key, $id);
}
//make sure all field IDs are numeric - TODO: ask Steph if this is redundant
//.........这里部分代码省略.........