public static function import_csv($path, $form_id, $field_ids, $entry_key = 0, $start_row = 2, $del = ',', $max = 250) { global $importing_fields, $wpdb, $frmpro_settings; if (!defined('WP_IMPORTING')) { define('WP_IMPORTING', true); } $form_id = (int) $form_id; if (!$form_id) { return $start_row; } if (!$importing_fields) { $importing_fields = array(); } if (!ini_get('safe_mode')) { set_time_limit(0); } //Remove time limit to execute this function if ($f = fopen($path, "r")) { unset($path); global $frm_entry, $frmdb, $frm_field; $row = 0; //setlocale(LC_ALL, get_locale()); while (($data = fgetcsv($f, 100000, $del)) !== FALSE) { $row++; if ($start_row > $row) { continue; } $values = array('form_id' => $form_id); $values['item_meta'] = array(); foreach ($field_ids as $key => $field_id) { $data[$key] = isset($data[$key]) ? $data[$key] : ''; if (is_numeric($field_id)) { if (isset($importing_fields[$field_id])) { $field = $importing_fields[$field_id]; } else { $field = $frm_field->getOne($field_id); $importing_fields[$field_id] = $field; } $values['item_meta'][$field_id] = apply_filters('frm_import_val', $data[$key], $field); switch ($field->type) { case 'user_id': $values['item_meta'][$field_id] = FrmProAppHelper::get_user_id_param(trim($values['item_meta'][$field_id])); $_POST['frm_user_id'] = $values['frm_user_id'] = $values['item_meta'][$field_id]; break; case 'checkbox': case 'select': $values['item_meta'][$field_id] = self::get_multi_opts($values['item_meta'][$field_id], $field); break; case 'data': $values['item_meta'][$field_id] = self::get_dfe_id($values['item_meta'][$field_id], $field, array(), $values); break; case 'file': $values['item_meta'][$field_id] = self::get_file_id($values['item_meta'][$field_id]); break; case 'date': $values['item_meta'][$field_id] = self::get_date($values['item_meta'][$field_id]); break; } if (isset($_POST['item_meta'][$field_id]) and ($field->type == 'checkbox' or $field->type == 'data' and $field->field_options['data_type'] != 'checkbox')) { if (empty($values['item_meta'][$field_id])) { $values['item_meta'][$field_id] = $_POST['item_meta'][$field_id]; } else { if (!empty($_POST['item_meta'][$field_id])) { $values['item_meta'][$field_id] = array_merge((array) $_POST['item_meta'][$field_id], (array) $values['item_meta'][$field_id]); } } } $_POST['item_meta'][$field_id] = $values['item_meta'][$field_id]; FrmProEntryMetaHelper::set_post_fields($field, $values['item_meta'][$field_id]); unset($field); } else { if (is_array($field_id)) { $field_type = isset($field_id['type']) ? $field_id['type'] : false; $linked = isset($field_id['linked']) ? $field_id['linked'] : false; $field_id = $field_id['field_id']; if ($field_type == 'data') { if ($linked) { $entry_id = $frmdb->get_var($frmdb->entry_metas, array('meta_value' => $data[$key], 'field_id' => $linked), 'item_id'); } else { //get entry id of entry with item_key == $data[$key] $entry_id = $frmdb->get_var($frmdb->entries, array('item_key' => $data[$key])); } if ($entry_id) { $values['item_meta'][$field_id] = $entry_id; } } unset($field_type); unset($linked); } else { $values[$field_id] = $data[$key]; } } } if (!isset($values['item_key']) or empty($values['item_key'])) { $values['item_key'] = $data[$entry_key]; } $offset = get_option('gmt_offset') * 60 * 60; foreach (array('created_at', 'updated_at') as $stamp) { if (!isset($values[$stamp])) { continue; } // adjust the date format if it starts with the day if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}/', trim($values[$stamp])) && substr($frmpro_settings->date_format, 0, 1) == 'd') { $reg_ex = str_replace(array('/', '.', '-', 'd', 'j', 'm', 'y', 'Y'), array('\\/', '\\.', '\\-', '\\d{2}', '\\d', '\\d{2}', '\\d{2}', '\\d{4}'), $frmpro_settings->date_format); if (preg_match('/^' . $reg_ex . '/', trim($values[$stamp]))) { $values[$stamp] = FrmProAppHelper::convert_date($values[$stamp], $frmpro_settings->date_format, 'Y-m-d H:i:s'); } } $values[$stamp] = date('Y-m-d H:i:s', strtotime($values[$stamp]) - $offset); unset($stamp); } unset($offset); if (isset($values['user_id'])) { $values['user_id'] = FrmProAppHelper::get_user_id_param($values['user_id']); } if (isset($values['updated_by'])) { $values['updated_by'] = FrmProAppHelper::get_user_id_param($values['updated_by']); } if (isset($values['is_draft'])) { $values['is_draft'] = (int) $values['is_draft']; } $editing = false; if (isset($values['id']) && $values['item_key']) { //check for updating by entry ID $editing = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_items WHERE form_id=%d AND id=%d", $values['form_id'], $values['id'])); } if ($editing) { $created = $frm_entry->update($values['id'], $values); } else { $created = $frm_entry->create($values); } unset($_POST); unset($values); unset($created); if ($row - $start_row >= $max) { fclose($f); return $row; } } fclose($f); return $row; } }
public static function show_entry_shortcode($atts) { $atts = shortcode_atts(array('id' => false, 'entry' => false, 'fields' => false, 'plain_text' => false, 'user_info' => false, 'include_blank' => false, 'default_email' => false, 'form_id' => false, 'format' => 'text', 'direction' => 'ltr', 'font_size' => '', 'text_color' => '', 'border_width' => '', 'border_color' => '', 'bg_color' => '', 'alt_bg_color' => ''), $atts); extract($atts); if ($format != 'text') { //format options are text, array, or json $plain_text = true; } global $frm_entry; if (!$entry || !is_object($entry)) { if (!$id && !$default_email) { return ''; } if ($id) { $entry = $frm_entry->getOne($id, true); } } if ($entry) { $form_id = $entry->form_id; $id = $entry->id; } if (!$fields || !is_array($fields)) { global $frm_field; $fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order'); } $content = $format != 'text' ? array() : ''; $odd = true; if (!$plain_text) { global $frmpro_settings; $default_settings = array('border_color' => 'dddddd', 'bg_color' => 'f7f7f7', 'text_color' => '444444', 'font_size' => '12px', 'border_width' => '1px', 'alt_bg_color' => 'ffffff'); // merge defaults, global settings, and shortcode options foreach ($default_settings as $key => $setting) { if ($atts[$key] != '') { continue; } if ($frmpro_settings) { if ('alt_bg_color' == $key) { $atts[$key] = $frmpro_settings->bg_color_active; } else { if ('border_width' == $key) { $atts[$key] = $frmpro_settings->field_border_width; } else { $atts[$key] = $frmpro_settings->{$key}; } } } else { $atts[$key] = $setting; } unset($key, $setting); } unset($default_settings); $content .= "<table cellspacing='0' style='font-size:{$atts['font_size']};line-height:135%; border-bottom:{$atts['border_width']} solid #{$atts['border_color']};'><tbody>\r\n"; $bg_color = " style='background-color:#{$atts['bg_color']};'"; $bg_color_alt = " style='background-color:#{$atts['alt_bg_color']};'"; $row_style = "style='text-align:" . ($direction == 'rtl' ? 'right' : 'left') . ";color:#{$atts['text_color']};padding:7px 9px;border-top:{$atts['border_width']} solid #{$atts['border_color']}'"; } foreach ($fields as $f) { if (in_array($f->type, array('divider', 'captcha', 'break', 'html'))) { continue; } if ($entry && !isset($entry->metas[$f->id])) { if ($entry->post_id && ($f->type == 'tag' || isset($f->field_options['post_field']) && $f->field_options['post_field'])) { $p_val = FrmProEntryMetaHelper::get_post_value($entry->post_id, $f->field_options['post_field'], $f->field_options['custom_field'], array('truncate' => $f->field_options['post_field'] == 'post_category' ? true : false, 'form_id' => $entry->form_id, 'field' => $f, 'type' => $f->type, 'exclude_cat' => isset($f->field_options['exclude_cat']) ? $f->field_options['exclude_cat'] : 0)); if ($p_val != '') { $entry->metas[$f->id] = $p_val; } } if (!isset($entry->metas[$f->id]) && !$include_blank && !$default_email) { continue; } $entry->metas[$f->id] = $default_email ? '[' . $f->id . ']' : ''; } $val = ''; if ($entry) { $prev_val = maybe_unserialize($entry->metas[$f->id]); $meta = array('item_id' => $id, 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type); $val = $default_email ? $prev_val : apply_filters('frm_email_value', $prev_val, (object) $meta, $entry); } else { if ($default_email) { $val = '[' . $f->id . ']'; } } if ($f->type == 'textarea' and !$plain_text) { $val = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $val); } //Remove signature from default-message shortcode if ($f->type == 'signature' && !$default_email) { continue; } if (is_array($val) && $format == 'text') { $val = implode(', ', $val); } $fname = $default_email ? '[' . $f->id . ' show=field_label]' : $f->name; if ($format != 'text') { $content[$f->field_key] = $val; } else { if ($plain_text) { if ('rtl' == $direction) { $content .= $val . ' :' . $fname . "\r\n\r\n"; } else { $content .= $fname . ': ' . $val . "\r\n\r\n"; } } else { if (!$default_email) { $content .= '<tr' . ($odd ? $bg_color : $bg_color_alt) . '>'; if ('rtl' == $direction) { $content .= "<td {$row_style}>{$val}</td><th {$row_style}>" . $fname . "</th>"; } else { $content .= "<th {$row_style}>" . $fname . "</th><td {$row_style}>{$val}</td>"; } $content .= '</tr>' . "\r\n"; $odd = $odd ? false : true; } else { $content .= '[if ' . $f->id . ']<tr style="[frm-alt-color]">'; if ('rtl' == $direction) { $content .= "<td {$row_style}>{$val}</td><th {$row_style}>" . $fname . "</th>"; } else { $content .= "<th {$row_style}>" . $fname . "</th><td {$row_style}>{$val}</td>"; } $content .= "</tr>\r\n[/if {$f->id}]"; } } } unset($fname, $f); } if ($user_info) { if (isset($entry->description)) { $data = maybe_unserialize($entry->description); } else { if ($default_email) { $entry->ip = '[ip]'; $data = array('browser' => '[browser]', 'referrer' => '[referrer]'); } } if ($format != 'text') { $content['ip'] = $entry->ip; $content['browser'] = $data['browser']; $content['referrer'] = $data['referrer']; } else { if ($plain_text) { $content .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n"; if ('rtl' == $direction) { $content .= $entry->ip . ' :' . __('IP Address', 'formidable') . "\r\n"; $content .= $data['browser'] . ' :' . __('User-Agent (Browser/OS)', 'formidable') . "\r\n"; $content .= $data['referrer'] . ' :' . __('Referrer', 'formidable') . "\r\n"; } else { $content .= __('IP Address', 'formidable') . ': ' . $entry->ip . "\r\n"; $content .= __('User-Agent (Browser/OS)', 'formidable') . ': ' . $data['browser'] . "\r\n"; $content .= __('Referrer', 'formidable') . ': ' . $data['referrer'] . "\r\n"; } } else { $content .= '<tr' . ($odd ? $bg_color : $bg_color_alt) . '>'; if ('rtl' == $direction) { $content .= "<td {$row_style}>" . $entry->ip . "</td><th {$row_style}>" . __('IP Address', 'formidable') . "</th>"; } else { $content .= "<th {$row_style}>" . __('IP Address', 'formidable') . "</th><td {$row_style}>" . $entry->ip . "</td>"; } $content .= '</tr>' . "\r\n"; $odd = $odd ? false : true; if (isset($data['browser'])) { $content .= '<tr' . ($odd ? $bg_color : $bg_color_alt) . '>'; if ('rtl' == $direction) { $content .= "<td {$row_style}>" . $data['browser'] . "</td><th {$row_style}>" . __('User-Agent (Browser/OS)', 'formidable') . "</th>"; } else { $content .= "<th {$row_style}>" . __('User-Agent (Browser/OS)', 'formidable') . "</th><td {$row_style}>" . $data['browser'] . "</td>"; } $content .= '</tr>' . "\r\n"; } $odd = $odd ? false : true; if (isset($data['referrer'])) { $content .= '<tr' . ($odd ? $bg_color : $bg_color_alt) . '>'; if ('rtl' == $direction) { $content .= "<td {$row_style}>" . str_replace("\r\n", '<br/>', $data['referrer']) . "</td><th {$row_style}>" . __('Referrer', 'formidable') . "</th>"; } else { $content .= "<th {$row_style}>" . __('Referrer', 'formidable') . "</th><td {$row_style}>" . str_replace("\r\n", '<br/>', $data['referrer']) . "</td>"; } $content .= '</tr>' . "\r\n"; } } } } if (!$plain_text) { $content .= '</tbody></table>'; } if ($format == 'json') { $content = json_encode($content); } return $content; }
private static function fill_field_defaults($field, $record, array &$values, $args) { $post_values = $args['post_values']; if ($args['default']) { $meta_value = $field->default_value; } else { if ($record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field']) { if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field)); } else { $meta_value = FrmEntryMeta::get_meta_value($record, $field->id); } } $field_type = isset($post_values['field_options']['type_' . $field->id]) ? $post_values['field_options']['type_' . $field->id] : $field->type; $new_value = isset($post_values['item_meta'][$field->id]) ? maybe_unserialize($post_values['item_meta'][$field->id]) : $meta_value; $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); $args['field_type'] = $field_type; self::fill_field_opts($field, $field_array, $args); $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); if (!isset($field_array['unique']) || !$field_array['unique']) { $field_array['unique_msg'] = ''; } $field_array = array_merge($field->field_options, $field_array); $values['fields'][$field->id] = $field_array; }
public static function set_post_fields($field, $value, $errors = null) { $field->field_options = maybe_unserialize($field->field_options); if (!isset($field->field_options['post_field']) || $field->field_options['post_field'] == '') { if (isset($errors)) { return $errors; } return; } if ($field->type == 'file') { global $frm_vars; if (!isset($frm_vars['media_id'])) { $frm_vars['media_id'] = array(); } $frm_vars['media_id'][$field->id] = $value; } global $frmpro_settings; if ($value && !empty($value) && isset($field->field_options['unique']) && $field->field_options['unique']) { global $frmdb; $entry_id = isset($_POST) && isset($_POST['id']) ? $_POST['id'] : false; $post_id = $entry_id ? $frmdb->get_var($frmdb->entries, array('id' => $entry_id), 'post_id') : false; if (isset($errors) && FrmProEntryMetaHelper::post_value_exists($field->field_options['post_field'], $value, $post_id, $field->field_options['custom_field'])) { $errors['field' . $field->id] = FrmProFieldsHelper::get_error_msg($field, 'unique_msg'); } unset($entry_id); unset($post_id); } if ($field->field_options['post_field'] == 'post_custom') { if ($field->type == 'date' and !preg_match('/^\\d{4}-\\d{2}-\\d{2}/', trim($value))) { $value = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d'); } $_POST['frm_wp_post_custom'][$field->id . '=' . $field->field_options['custom_field']] = $value; if (isset($errors)) { return $errors; } return; } if ($field->field_options['post_field'] == 'post_date') { if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}/', trim($value))) { $value = FrmProAppHelper::convert_date($value, $frmpro_settings->date_format, 'Y-m-d H:i:s'); } } else { if ($field->type != 'tag' && $field->field_options['post_field'] == 'post_category') { $value = (array) $value; // change text to numeric ids if (defined('WP_IMPORTING')) { foreach ($value as $k => $val) { if (empty($val)) { continue; } $term = term_exists($val, $field->field_options['taxonomy']); if ($term) { $value[$k] = is_array($term) ? $term['term_id'] : $term; } unset($k, $val, $term); } } if (isset($field->field_options['taxonomy']) && $field->field_options['taxonomy'] != 'category') { $new_value = array(); foreach ($value as $val) { if ($val == 0) { continue; } $term = get_term($val, $field->field_options['taxonomy']); if (!isset($term->errors)) { $new_value[$val] = $term->name; } else { $new_value[$val] = $val; } unset($term); } if (!isset($_POST['frm_tax_input'])) { $_POST['frm_tax_input'] = array(); } if (isset($_POST['frm_tax_input'][$field->field_options['taxonomy']])) { foreach ($new_value as $new_key => $new_name) { $_POST['frm_tax_input'][$field->field_options['taxonomy']][$new_key] = $new_name; } } else { $_POST['frm_tax_input'][$field->field_options['taxonomy']] = $new_value; } } else { $_POST['frm_wp_post'][$field->id . '=' . $field->field_options['post_field']] = $value; } } else { if ($field->type == 'tag' && $field->field_options['post_field'] == 'post_category') { $value = trim($value); $value = array_map('trim', explode(',', $value)); $tax_type = isset($field->field_options['taxonomy']) && !empty($field->field_options['taxonomy']) ? $field->field_options['taxonomy'] : 'frm_tag'; if (!isset($_POST['frm_tax_input'])) { $_POST['frm_tax_input'] = array(); } if (is_taxonomy_hierarchical($tax_type)) { //create the term or check to see if it exists $terms = array(); foreach ($value as $v) { $term_id = term_exists($v, $tax_type); if (!$term_id) { $term_id = wp_insert_term($v, $tax_type); } if ($term_id && is_array($term_id)) { $term_id = $term_id['term_id']; } if (is_numeric($term_id)) { $terms[$term_id] = $v; } unset($term_id); unset($v); } $value = $terms; unset($terms); } if (!isset($_POST['frm_tax_input'][$tax_type])) { $_POST['frm_tax_input'][$tax_type] = (array) $value; } else { $_POST['frm_tax_input'][$tax_type] += (array) $value; } } } } if ($field->field_options['post_field'] != 'post_category') { $_POST['frm_wp_post'][$field->id . '=' . $field->field_options['post_field']] = $value; } if (isset($errors)) { return $errors; } }
function entry_link_shortcode($atts) { global $user_ID, $frm_entry, $frm_entry_meta, $post; extract(shortcode_atts(array('id' => false, 'field_key' => 'created_at', 'type' => 'list', 'logged_in' => true, 'edit' => true, 'class' => '', 'link_type' => 'page', 'blank_label' => '', 'param_name' => 'entry', 'param_value' => 'key', 'page_id' => false, 'show_delete' => false), $atts)); if (!$id or $logged_in && !$user_ID) { return; } $id = (int) $id; if ($show_delete === 1) { $show_delete = __('Delete', 'formidable'); } $s = FrmAppHelper::get_param('frm_search', false); if ($s) { $entry_ids = FrmProEntriesHelper::get_search_ids($s, $id); } else { $entry_ids = $frm_entry_meta->getEntryIds("fi.form_id='{$id}'"); } if ($entry_ids) { $id_list = implode(',', $entry_ids); $order = $type == 'collapse' ? ' ORDER BY it.created_at DESC' : ''; $where = "it.id in ({$id_list})"; if ($logged_in) { $where .= " and it.form_id='" . $id . "' and it.user_id='" . (int) $user_ID . "'"; } $entries = $frm_entry->getAll($where, $order, '', true); } if (!empty($entries)) { if ($type == 'list') { $content = "<ul class='frm_entry_ul {$class}'>\n"; } else { if ($type == 'collapse') { $content = '<div class="frm_collapse">'; $year = $month = ''; $prev_year = $prev_month = false; } else { $content = "<select id='frm_select_form_{$id}' name='frm_select_form_{$id}' class='{$class}' onchange='location=this.options[this.selectedIndex].value;'>\n <option value='" . get_permalink($post->ID) . "'>{$blank_label}</option>\n"; } } global $frm_field; if ($field_key != 'created_at') { $field = $frm_field->getOne($field_key); } foreach ($entries as $entry) { $action = (isset($_GET) and isset($_GET['frm_action'])) ? 'frm_action' : 'action'; if (isset($_GET) and isset($_GET[$action]) and $_GET[$action] == 'destroy') { if (isset($_GET['entry']) and ($_GET['entry'] == $entry->item_key or $_GET['entry'] == $entry->id)) { continue; } } if ($entry->post_id) { global $wpdb; $post_status = $wpdb->get_var("SELECT post_status FROM {$wpdb->posts} WHERE ID=" . $entry->post_id); if ($post_status != 'publish') { continue; } } $value = ''; $meta = false; if ($field_key && $field_key != 'created_at') { if ($entry->post_id and ($field and $field->field_options['post_field'] or $field->type == 'tag')) { $value = FrmProEntryMetaHelper::get_post_value($entry->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('type' => $field->type, 'form_id' => $field->form_id, 'field' => $field)); } else { $meta = isset($entry->metas[$field_key]) ? $entry->metas[$field_key] : ''; } } else { $meta = reset($entry->metas); } $value = ($field_key == 'created_at' or !isset($meta) or !$meta) ? $value : (is_object($meta) ? $meta->meta_value : $meta); if (empty($value)) { $value = date_i18n(get_option('date_format'), strtotime($entry->created_at)); } else { $value = FrmProEntryMetaHelper::display_value($value, $field, array('type' => $field->type, 'show_filename' => false)); } if ($param_value == 'key') { $args = array($param_name => $entry->item_key); } else { $args = array($param_name => $entry->id); } if ($edit) { $args['frm_action'] = 'edit'; } if ($link_type == 'scroll') { $link = '#' . $entry->item_key; } else { if ($link_type == 'admin') { $link = add_query_arg($args, $_SERVER['REQUEST_URI']); } else { if ($page_id) { $permalink = get_permalink($page_id); } else { $permalink = get_permalink($post->ID); } $link = add_query_arg($args, $permalink); } } unset($args); $current = isset($_GET['entry']) && $_GET['entry'] == $entry->item_key ? true : false; if ($type == 'list') { $content .= "<li><a href='{$link}'>" . stripslashes($value) . "</a>"; if ($show_delete and isset($permalink) and FrmProEntriesHelper::allow_delete($entry)) { $content .= " <a href='" . add_query_arg(array('frm_action' => 'destroy', 'entry' => $entry->id), $permalink) . "' class='frm_delete_list'>{$show_delete}</a>\n"; } $content .= "</li>\n"; } else { if ($type == 'collapse') { $new_year = strftime('%G', strtotime($entry->created_at)); $new_month = strftime('%B', strtotime($entry->created_at)); if ($new_year != $year) { if ($prev_year) { if ($prev_month) { $content .= '</ul></div>'; } $content .= '</div>'; $prev_month = false; } $style = $prev_year ? " style='display:none'" : ''; $triangle = $prev_year ? "e" : "s"; $content .= "\n<div class='frm_year_heading frm_year_heading_{$id}'>\n <span class='ui-icon ui-icon-triangle-1-{$triangle}'></span>\n\n <a>{$new_year}</a></div>\n\n <div class='frm_toggle_container' {$style}>\n"; $prev_year = true; } if ($new_month != $month) { if ($prev_month) { $content .= '</ul></div>'; } $style = $prev_month ? " style='display:none'" : ''; $triangle = $prev_month ? "e" : "s"; $content .= "<div class='frm_month_heading frm_month_heading_{$id}'>\n <span class='ui-icon ui-icon-triangle-1-{$triangle}'></span>\n\n <a>{$new_month}</a>\n</div>\n\n <div class='frm_toggle_container frm_month_listing' {$style}><ul>\n"; $prev_month = true; } $content .= "<li><a href='{$link}'>" . stripslashes($value) . "</a></li>"; $year = $new_year; $month = $new_month; } else { $selected = $current ? ' selected="selected"' : ''; $content .= "<option value='{$link}'{$selected}>" . stripslashes($value) . "</option>\n"; } } } if ($type == 'list') { $content .= "</ul>\n"; } else { if ($type == 'collapse') { if ($prev_year) { $content .= '</div>'; } if ($prev_month) { $content .= '</ul></div>'; } $content .= '</div>'; $content .= "<script type='text/javascript'>jQuery(document).ready(function(\$){ \$('.frm_month_heading_" . $id . ", .frm_year_heading_" . $id . "').toggle(function(){ \$(this).children('.ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s'); \$(this).children('.ui-icon-triangle-1-s').removeClass('ui-icon-triangle-1-e'); \$(this).next('.frm_toggle_container').fadeIn('slow');},function(){ \$(this).children('.ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e'); \$(this).children('.ui-icon-triangle-1-e').removeClass('ui-icon-triangle-1-s'); \$(this).next('.frm_toggle_container').hide();});})</script>\n"; } else { $content .= "</select>\n"; if ($show_delete and isset($_GET) and isset($_GET['entry']) and $_GET['entry']) { $content .= " <a href='" . add_query_arg(array('frm_action' => 'destroy', 'entry' => $_GET['entry']), $permalink) . "' class='frm_delete_list'>{$show_delete}</a>\n"; } } } } else { $content = ''; } return $content; }
function replace_shortcodes($content, $entry, $shortcodes, $display = false, $show = 'one', $odd = '') { global $frm_field, $frm_entry_meta, $post, $frmpro_settings; if ($display) { $param_value = $display->type == 'id' ? $entry->id : $entry->item_key; if ($entry->post_id) { $detail_link = get_permalink($entry->post_id); } else { $param = isset($display->param) && !empty($display->param) ? $display->param : 'entry'; if ($post) { $detail_link = add_query_arg($param, $param_value, get_permalink($post->ID)); } else { $detail_link = add_query_arg($param, $param_value); } //if( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // $detail_link = get_permalink($post->ID) .$param_value .'/'; } } foreach ($shortcodes[0] as $short_key => $tag) { $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false; $atts = shortcode_parse_atts($shortcodes[3][$short_key]); if (!empty($shortcodes[3][$short_key])) { if ($conditional) { $tag = str_replace('[if ', '', $shortcodes[0][$short_key]); } else { $tag = str_replace('[', '', $shortcodes[0][$short_key]); } $tag = str_replace(']', '', $tag); $tags = explode(' ', $tag); if (is_array($tags)) { $tag = $tags[0]; } } else { $tag = $shortcodes[2][$short_key]; } switch ($tag) { case 'detaillink': if ($display and $detail_link) { $content = str_replace($shortcodes[0][$short_key], $detail_link, $content); } break; case 'id': $content = str_replace($shortcodes[0][$short_key], $entry->id, $content); break; case 'post-id': case 'post_id': $content = str_replace($shortcodes[0][$short_key], $entry->post_id, $content); break; case 'key': $content = str_replace($shortcodes[0][$short_key], $entry->item_key, $content); break; case 'ip': $content = str_replace($shortcodes[0][$short_key], $entry->ip, $content); break; case 'user_agent': case 'user-agent': $entry->description = maybe_unserialize($entry->description); $content = str_replace($shortcodes[0][$short_key], $entry->description['browser'], $content); break; case 'created-at': case 'updated-at': if (!isset($atts['format'])) { $atts['format'] = get_option('date_format'); $time_format = false; } else { $time_format = ' '; } $this_tag = str_replace('-', '_', $tag); if ($conditional) { $replace_with = apply_filters('frm_conditional_value', $entry->{$this_tag}, $atts, false, $tag); if ($atts) { $content = str_replace($shortcodes[0][$short_key], '[if ' . $tag . ']', $content); } if (empty($replace_with)) { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])(.*?)(\\[\\/if\\s+' . $tag . '\\])/mis', '', $content); } else { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])/', '', $content, 1); $content = preg_replace('/(\\[\\/if\\s+' . $tag . '\\])/', '', $content, 1); } } else { if (isset($atts['time_ago'])) { $date = FrmProAppHelper::human_time_diff(strtotime($entry->{$this_tag})); } else { $date = FrmProAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); } $content = str_replace($shortcodes[0][$short_key], $date, $content); } unset($this_tag); break; case 'evenodd': $content = str_replace($shortcodes[0][$short_key], $odd, $content); break; case 'siteurl': global $frm_siteurl; $content = str_replace($shortcodes[0][$short_key], $frm_siteurl, $content); break; case 'sitename': $content = str_replace($shortcodes[0][$short_key], get_option('blogname'), $content); break; case 'get': if (isset($atts['param'])) { $param = $atts['param']; $replace_with = FrmAppHelper::get_param($param); if (is_array($replace_with)) { $replace_with = implode(', ', $replace_with); } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); unset($param); unset($replace_with); } break; default: if ($tag == 'deletelink') { $page_id = isset($atts['page_id']) ? $atts['page_id'] : $post->ID; $can_delete = FrmProEntriesHelper::allow_delete($entry); if ($can_delete) { if (isset($atts['label'])) { $delete_atts = $atts; $delete_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_delete_link($delete_atts); unset($delete_atts); } else { $replace_with = add_query_arg(array('frm_action' => 'destroy', 'entry' => $entry->id), get_permalink($page_id)); } } else { $replace_with = ''; } $field = false; } else { if ($tag == 'editlink') { $replace_with = ''; $link_text = isset($atts['label']) ? $atts['label'] : false; if (!$link_text) { $link_text = isset($atts['link_text']) ? $atts['link_text'] : __('Edit', 'formidable'); } $class = isset($atts['class']) ? $atts['class'] : ''; $page_id = isset($atts['page_id']) ? $atts['page_id'] : $post->ID; if (isset($atts['location']) and $atts['location'] == 'front') { $edit_atts = $atts; $edit_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_edit_link($edit_atts); } else { if ($entry->post_id) { $replace_with = get_edit_post_link($entry->post_id); } else { global $frm_siteurl; if (current_user_can('frm_edit_entries')) { $replace_with = esc_url($frm_siteurl . '/wp-admin/admin.php?page=formidable-entries&frm_action=edit&id=' . $entry->id); } } if (!empty($replace_with)) { $replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>'; } } unset($class); } else { $field = $frm_field->getOne($tag); } } $sep = isset($atts['sep']) ? $atts['sep'] : ', '; if (!isset($field)) { $field = false; } if ($field) { $field->field_options = maybe_unserialize($field->field_options); $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts); $replace_with = maybe_unserialize($replace_with); $atts['entry_id'] = $entry->id; $atts['entry_key'] = $entry->item_key; $atts['post_id'] = $entry->post_id; $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field); } if (isset($replace_with) and is_array($replace_with)) { $replace_with = implode($sep, $replace_with); } if ($field and $field->type == 'file') { //size options are thumbnail, medium, large, or full $size = isset($atts['size']) ? $atts['size'] : 'thumbnail'; if ($size != 'id') { $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size); } } if ($conditional) { $replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag); if ($atts) { $content = str_replace($shortcodes[0][$short_key], '[if ' . $tag . ']', $content); } if (empty($replace_with)) { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])(.*?)(\\[\\/if\\s+' . $tag . '\\])/mis', '', $content); } else { $content = preg_replace('/(\\[if\\s+' . $tag . '\\])/', '', $content, 1); $content = preg_replace('/(\\[\\/if\\s+' . $tag . '\\])/', '', $content, 1); } } else { if ($field) { if (isset($atts['show']) and $atts['show'] == 'field_label') { $replace_with = stripslashes($field->name); } else { if (empty($replace_with) and $replace_with != '0') { $replace_with = ''; if ($field->type == 'number') { $replace_with = '0'; } } else { $replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts); } } } if (isset($atts['sanitize'])) { $replace_with = sanitize_title_with_dashes($replace_with); } if (isset($atts['sanitize_url'])) { $replace_with = urlencode(htmlentities($replace_with)); } if (isset($atts['truncate'])) { if (isset($atts['more_text'])) { $more_link_text = $atts['more_text']; } else { $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .'; } if ($display and $show == 'all') { $more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>'; $replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text); } else { $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES); $part_one = substr($replace_with, 0, (int) $atts['truncate']); $part_two = substr($replace_with, (int) $atts['truncate']); $replace_with = $part_one . '<a onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\')" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>'; } } if (isset($atts['clickable'])) { $replace_with = make_clickable($replace_with); } if (!isset($replace_with)) { $replace_with = ''; } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($replace_with); if (isset($field)) { unset($field); } } unset($atts); unset($conditional); } return $content; }
function single_row($item, $style = '') { global $frmpro_settings; $checkbox = ''; // Set up the hover actions for this user $actions = array(); $edit_link = "?page=formidable-{$this->page_name}&frm_action=edit&id={$item->id}"; $actions['edit'] = "<a href='" . wp_nonce_url($edit_link) . "'>" . __('Edit', 'formidable') . "</a>"; $duplicate_link = "?page=formidable-{$this->page_name}&frm_action=duplicate&id={$item->id}"; $delete_link = "?page=formidable-{$this->page_name}&frm_action=destroy&id={$item->id}"; if ($this->plural == 'entries') { $duplicate_link .= "&form=" . $this->params['form']; $delete_link .= "&form=" . $this->params['form']; $view_link = "?page=formidable-{$this->page_name}&frm_action=show&id={$item->id}"; $actions['view'] = "<a href='" . wp_nonce_url($view_link) . "'>" . __('View', 'formidable') . "</a>"; } $actions['duplicate'] = "<a href='" . wp_nonce_url($duplicate_link) . "'>" . __('Duplicate', 'formidable') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($delete_link) . "' onclick='return confirm(\"" . __('Are you sure you want to delete that?', 'formidable') . "\")'>" . __('Delete', 'formidable') . "</a>"; if ($this->plural == 'displays' and !current_user_can('frm_edit_displays')) { $actions = array(); } else { if ($this->plural == 'entries') { if (!current_user_can('frm_edit_entries')) { unset($actions['edit']); } if (!current_user_can('frm_create_entries')) { unset($actions['duplicate']); } if (!current_user_can('frm_delete_entries')) { unset($actions['delete']); } } } $action_links = $this->row_actions($actions); // Set up the checkbox ( because the user is editable, otherwise its empty ) $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; $r = "<tr id='item-action-{$item->id}'{$style}>"; list($columns, $hidden) = $this->get_column_info(); $action_col = false; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } else { if (!$action_col and !in_array($column_name, array('cb', 'id', 'form_id', 'post_id'))) { $action_col = $column_name; } } $attributes = "{$class}{$style}"; $col_name = preg_replace('/^(' . $this->params['form'] . '_)/', '', $column_name); switch ($col_name) { case 'cb': $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; break; case 'ip': case 'id': case 'item_key': case 'display_key': case 'show_count': $val = stripslashes($item->{$col_name}); break; case 'name': case 'description': case 'content': case 'dyncontent': $val = FrmAppHelper::truncate(strip_tags(stripslashes($item->{$col_name})), 100); break; case 'created_at': case 'updated_at': $date = date($frmpro_settings->date_format, strtotime($item->{$col_name})); $val = "<abbr title='" . date($frmpro_settings->date_format . ' g:i:s A', strtotime($item->{$col_name})) . "'>" . $date . "</abbr>"; break; case 'form_id': global $frm_form; $form = $frm_form->getName($item->form_id); if ($form) { $val = '<a href="' . admin_url('admin.php') . '?page=formidable&frm_action=edit&id=' . $item->form_id . '">' . FrmAppHelper::truncate(stripslashes($form), 40) . '</a>'; } else { $val = ''; } break; case 'post_id': if ($this->plural == 'displays' and $item->insert_loc == 'none') { $val = ''; break; } $post = get_post($item->{$col_name}); if ($post) { $val = '<a href="' . admin_url('post.php') . '?post=' . $item->{$col_name} . '&action=edit">' . FrmAppHelper::truncate($post->post_title, 50) . '</a>'; } else { $val = ''; } break; case 'user_id': $user = get_userdata($item->user_id); $val = $user->user_login; break; case 'shortcode': if ($this->plural == 'displays') { $code = "[display-frm-data id={$item->id} filter=1]"; } else { $code = ''; } $val = "<input type='text' style='font-size:10px;width:100%;' readonly='true' onclick='this.select();' onfocus='this.select();' value='{$code}' />"; break; default: if ($this->plural == 'entries') { global $frm_field; $col = $frm_field->getOne($col_name); $field_value = isset($item->metas[$col->id]) ? $item->metas[$col->id] : false; $col->field_options = maybe_unserialize($col->field_options); if (!$field_value and $col->type == 'data' and $col->field_options['data_type'] == 'data' and isset($col->field_options['hide_field'])) { $field_value = array(); foreach ((array) $col->field_options['hide_field'] as $hfield) { if (isset($item->metas[$hfield])) { $field_value[] = maybe_unserialize($item->metas[$hfield]); } } } $val = FrmProEntryMetaHelper::display_value($field_value, $col, array('type' => $col->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id)); } else { $val = $col_name; } break; } if (isset($val)) { $r .= "<td {$attributes}>"; if ($column_name == $action_col) { $r .= '<a class="row-title" href="' . (isset($actions['edit']) ? $edit_link : $view_link) . '">' . $val . '</a> '; $r .= $action_links; } else { $r .= $val; } $r .= '</td>'; } unset($val); } $r .= '</tr>'; return $r; }
echo esc_attr($entry_action . ' ' . stripslashes($item->name)); ?> "> <?php } $field_value = isset($item->metas[$col->id]) ? $item->metas[$col->id] : false; $col->field_options = maybe_unserialize($col->field_options); if (!$field_value and $col->type == 'data' and $col->field_options['data_type'] == 'data' and isset($col->field_options['hide_field'])) { $field_value = array(); foreach ((array) $col->field_options['hide_field'] as $hfield) { if (isset($item->metas[$hfield])) { $field_value[] = maybe_unserialize($item->metas[$hfield]); } } } echo FrmProEntryMetaHelper::display_value($field_value, $col, array('type' => $col->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id)); if ($col == $form_cols[0]) { ?> </a><br/> <div class="row-actions"> <span><a href="?page=formidable-entries&frm_action=show&id=<?php echo $item->id; ?> " title="<?php _e('View', 'formidable'); ?> <?php echo $item->item_key; ?> "><?php _e('View', 'formidable');
/** * Get the options for a dependent Dynamic field * * @since 2.0.16 * @param array $args * @param array $field */ private static function get_dependent_dynamic_field_options($args, &$field) { $linked_field = FrmField::getOne($args['linked_field_id']); $field['options'] = array(); $metas = array(); FrmProEntryMetaHelper::meta_through_join($args['trigger_field_id'], $linked_field, $args['entry_id'], $args['field_data'], $metas); $metas = stripslashes_deep($metas); if (FrmProFieldsHelper::include_blank_option($metas, $args['field_data'])) { $field['options'][''] = ''; } foreach ($metas as $meta) { $field['options'][$meta->item_id] = FrmEntriesHelper::display_value($meta->meta_value, $linked_field, array('type' => $linked_field->type, 'show_icon' => true, 'show_filename' => false)); unset($meta); } // change the form_select value so the filter doesn't override the values $args['field_data']->field_options['form_select'] = 'filtered_' . $args['field_data']->field_options['form_select']; $field = apply_filters('frm_setup_new_fields_vars', $field, $args['field_data']); // Sort the options $field['options'] = apply_filters('frm_data_sort', $field['options'], array('metas' => $metas, 'field' => $args['linked_field_id'])); }
public static function email_value($value, $meta, $entry) { global $frm_field, $frm_entry; if ($entry->id != $meta->item_id) { $entry = $frm_entry->getOne($meta->item_id); } $field = $frm_field->getOne($meta->field_id); if (!$field) { return $value; } $field->field_options = maybe_unserialize($field->field_options); if (isset($field->field_options['post_field']) and $field->field_options['post_field']) { $value = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, array('truncate' => true)); $value = maybe_unserialize($value); } switch ($field->type) { case 'user_id': $value = FrmProFieldsHelper::get_display_name($value); break; case 'data': if (is_array($value)) { $new_value = array(); foreach ($value as $val) { $new_value[] = FrmProFieldsHelper::get_data_value($val, $field); } $value = $new_value; } else { $value = FrmProFieldsHelper::get_data_value($value, $field); } break; case 'file': $value = self::get_file_name($value); break; /*case 'date': $value = FrmProFieldsHelper::get_date($value);*/ } if (is_array($value)) { $new_value = ''; foreach ($value as $val) { if (is_array($val)) { $new_value .= implode(', ', $val) . "\n"; } } if ($new_value != '') { $value = $new_value; } } return $value; }
public static function build_calendar($new_content, $entries, $shortcodes, $display, $show = 'one') { if (!$display || $display->frm_show_count != 'calendar' || $show == 'one') { return $new_content; } global $frm_entry_meta, $wp_locale, $frm_field; $current_year = date_i18n('Y'); $current_month = date_i18n('m'); $year = FrmAppHelper::get_param('frmcal-year', date('Y')); //4 digit year $month = FrmAppHelper::get_param('frmcal-month', $current_month); //Numeric month with leading zeros $timestamp = mktime(0, 0, 0, $month, 1, $year); $maxday = date('t', $timestamp); //Number of days in the given month $this_month = getdate($timestamp); $startday = $this_month['wday']; // week_begins = 0 stands for Sunday $week_begins = apply_filters('frm_cal_week_begins', intval(get_option('start_of_week')), $display); if ($week_begins > $startday) { $startday = $startday + 7; } $week_ends = 6 + (int) $week_begins; if ($week_ends > 6) { $week_ends = (int) $week_ends - 7; } if ($current_year == $year and $current_month == $month) { $today = date_i18n('j'); } $daily_entries = array(); if (isset($display->frm_date_field_id) && is_numeric($display->frm_date_field_id)) { $field = $frm_field->getOne($display->frm_date_field_id); } if (isset($display->frm_edate_field_id) && is_numeric($display->frm_edate_field_id)) { $efield = $frm_field->getOne($display->frm_edate_field_id); } else { $efield = false; } foreach ($entries as $entry) { if (isset($display->frm_date_field_id) && is_numeric($display->frm_date_field_id)) { if (isset($entry->metas)) { $date = isset($entry->metas[$display->frm_date_field_id]) ? $entry->metas[$display->frm_date_field_id] : false; } else { $date = $frm_entry_meta->get_entry_meta_by_field($entry->id, $display->frm_date_field_id); } if ($entry->post_id && !$date && $field && isset($field->field_options['post_field']) && $field->field_options['post_field']) { $date = FrmProEntryMetaHelper::get_post_value($entry->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('form_id' => $display->frm_form_id, 'type' => $field->type, 'field' => $field)); } } else { if ($display->frm_date_field_id == 'updated_at') { $date = $entry->updated_at; $i18n = true; } else { $date = $entry->created_at; $i18n = true; } } if (empty($date)) { continue; } if (isset($i18n) && $i18n) { $date = get_date_from_gmt($date); $date = date_i18n('Y-m-d', strtotime($date)); } else { $date = date('Y-m-d', strtotime($date)); } unset($i18n); $dates = array($date); if (isset($display->frm_edate_field_id) && !empty($display->frm_edate_field_id)) { if (is_numeric($display->frm_edate_field_id) and $efield) { $edate = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $efield); if ($efield && $efield->type == 'number' && is_numeric($edate)) { $edate = date('Y-m-d', strtotime('+' . ($edate - 1) . ' days', strtotime($date))); } } else { if ($display->frm_edate_field_id == 'updated_at') { $edate = get_date_from_gmt($entry->updated_at); $edate = date_i18n('Y-m-d', strtotime($edate)); } else { $edate = get_date_from_gmt($entry->created_at); $edate = date_i18n('Y-m-d', strtotime($edate)); } } if ($edate and !empty($edate)) { $from_date = strtotime($date); $to_date = strtotime($edate); if (!empty($from_date) and $from_date < $to_date) { for ($current_ts = $from_date; $current_ts <= $to_date; $current_ts += 60 * 60 * 24) { $dates[] = date('Y-m-d', $current_ts); } unset($current_ts); } unset($from_date); unset($to_date); } unset($edate); $used_entries = array(); } unset($date); //Recurring events if (isset($display->frm_repeat_event_field_id) && is_numeric($display->frm_repeat_event_field_id)) { if (isset($entry->metas)) { //When is $entry->metas not set? Is it when posts are created? $repeat_period = isset($entry->metas[$display->frm_repeat_event_field_id]) ? $entry->metas[$display->frm_repeat_event_field_id] : false; $stop_repeat = isset($entry->metas[$display->frm_repeat_edate_field_id]) ? $entry->metas[$display->frm_repeat_edate_field_id] : false; } else { //Test this else section $repeat_period = $frm_entry_meta->get_entry_meta_by_field($entry->id, $display->frm_repeat_event_field_id); $stop_repeat = $frm_entry_meta->get_entry_meta_by_field($entry->id, $display->frm_repeat_edate_field_id); } //If site is not set to English, convert day(s), week(s), month(s), and year(s) (in repeat_period string) to English //Check for a few common repeat periods like daily, weekly, monthly, and yearly as well $t_strings = array(__('day', 'formidable'), __('days', 'formidable'), __('daily', 'formidable'), __('week', 'formidable'), __('weeks', 'formidable'), __('weekly', 'formidable'), __('month', 'formidable'), __('months', 'formidable'), __('monthly', 'formidable'), __('year', 'formidable'), __('years', 'formidable'), __('yearly', 'formidable')); $t_strings = apply_filters('frm_recurring_strings', $t_strings, $display); $e_strings = array('day', 'days', '1 day', 'week', 'weeks', '1 week', 'month', 'months', '1 month', 'year', 'years', '1 year'); if ($t_strings != $e_strings) { $repeat_period = str_ireplace($t_strings, $e_strings, $repeat_period); } unset($t_strings, $e_strings); //Switch [frmcal-date] for current calendar date (for use in "Third Wednesday of [frmcal-date]") $repeat_period = str_replace('[frmcal-date]', $year . '-' . $month . '-01', $repeat_period); //Filter for repeat_period $repeat_period = apply_filters('frm_repeat_period', $repeat_period, $display); //If repeat period is set and is valid if (!empty($repeat_period) && is_numeric(strtotime($repeat_period))) { //Set up end date to minimize dates array - allow for no end repeat field set, nothing selected for end, or any date if (isset($display->frm_repeat_edate_field_id) && !empty($stop_repeat)) { //If field is selected for recurring end date and the date is not empty $maybe_stop_repeat = strtotime($stop_repeat); } //Repeat until next viewable month $cal_date = $year . '-' . $month . '-01'; $stop_repeat = strtotime('+1 month', strtotime($cal_date)); //If the repeat should end before $stop_repeat (+1 month), use $maybe_stop_repeat if (isset($maybe_stop_repeat) && $maybe_stop_repeat < $stop_repeat) { $stop_repeat = $maybe_stop_repeat; unset($maybe_stop_repeat); } $temp_dates = array(); foreach ($dates as $d) { $last_i = 0; for ($i = strtotime($d); $i <= $stop_repeat; $i = strtotime($repeat_period, $i)) { //Break endless loop if ($i == $last_i) { break; } $last_i = $i; //Add to dates array $temp_dates[] = date('Y-m-d', $i); } unset($last_i); unset($d); } $dates = $temp_dates; unset($repeat_period, $to_date, $start_date, $stop_repeat, $temp_dates); } } $dates = apply_filters('frm_show_entry_dates', $dates, $entry); for ($i = 0; $i < $maxday + $startday; $i++) { $day = $i - $startday + 1; if (in_array(date('Y-m-d', strtotime("{$year}-{$month}-{$day}")), $dates)) { $daily_entres[$i][] = $entry; } unset($day); } unset($dates); } $day_names = $wp_locale->weekday_abbrev; $day_names = FrmProAppHelper::reset_keys($day_names); //switch keys to order if ($week_begins) { for ($i = $week_begins; $i < $week_begins + 7; $i++) { if (!isset($day_names[$i])) { $day_names[$i] = $day_names[$i - 7]; } } unset($i); } ob_start(); include FrmAppHelper::plugin_path() . '/pro/classes/views/displays/calendar.php'; $content = ob_get_contents(); ob_end_clean(); return $content; }
public static function entry_created($entry_id, $form_id, $create = true) { if (defined('WP_IMPORTING')) { return; } global $frm_field, $frm_entry, $frm_entry_meta, $frmpro_settings; $frm_form = new FrmForm(); $form = $frm_form->getOne($form_id); if (!$form) { return; } $form_options = maybe_unserialize($form->options); $entry = $frm_entry->getOne($entry_id, true); if (!$entry or $entry->form_id != $form_id or $entry->is_draft) { return; } $sent_to = array(); $notifications = isset($form_options['notification']) ? $form_options['notification'] : array(0 => $form_options); $fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order'); $temp_fields = array(); foreach ($fields as $k => $f) { if (!isset($entry->metas[$f->id])) { $f->field_options = maybe_unserialize($f->field_options); if (isset($f->field_options['post_field']) and !empty($f->field_options['post_field'])) { //get value from linked post $entry->metas[$f->id] = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $f, array('links' => false)); if ($entry->metas[$f->id] == '') { //and !include_blank unset($entry->metas[$f->id]); } //}else if(include_blank){ // $entry->metas[$f->id] = ''; } } $temp_fields[$f->id] = $f; unset($fields[$k]); unset($k); unset($f); } $fields = $temp_fields; unset($temp_fields); $frm_notification = new FrmNotification(); foreach ($notifications as $email_key => $notification) { if (isset($notification['update_email'])) { if ($create and $notification['update_email'] == 2) { continue; } if (!$create and empty($notification['update_email'])) { continue; } } //check if conditions are met $stop = self::conditions_met($notification, $entry); if ($stop) { continue; } unset($stop); $to_email = explode(',', $notification['email_to']); $email_fields = isset($notification['also_email_to']) ? (array) $notification['also_email_to'] : array(); $email_fields = array_merge($email_fields, $to_email); $entry_ids = array($entry->id); $exclude_fields = array(); foreach ($email_fields as $key => $email_field) { $email_field = str_replace(array('[', ']'), '', trim($email_field)); if (is_numeric($email_field)) { $email_fields[$key] = (int) $email_field; } if (preg_match('/|/', $email_field)) { $email_opt = explode('|', $email_field); if (isset($email_opt[1])) { if (isset($entry->metas[$email_opt[0]])) { $add_id = $entry->metas[$email_opt[0]]; $add_id = maybe_unserialize($add_id); if (is_array($add_id)) { foreach ($add_id as $add) { $entry_ids[] = $add; } } else { $entry_ids[] = $add_id; } } //skip the data field if it will be fetched through the other form $exclude_fields[] = $email_opt[0]; $email_fields[$key] = (int) $email_opt[1]; } unset($email_opt); } } if (empty($to_email) and empty($email_fields)) { continue; } foreach ($email_fields as $email_field) { if (isset($notification['reply_to_name']) and preg_match('/|/', $email_field)) { $email_opt = explode('|', $notification['reply_to_name']); if (isset($email_opt[1])) { if (isset($entry->metas[$email_opt[0]])) { $entry_ids[] = $entry->metas[$email_opt[0]]; } //skip the data field if it will be fetched through the other form $exclude_fields[] = $email_opt[0]; } unset($email_opt); } } $where = ''; if (!empty($exclude_fields)) { $where = " and it.field_id not in (" . implode(',', $exclude_fields) . ")"; } $values = $frm_entry_meta->getAll("it.field_id != 0 and it.item_id in (" . implode(',', $entry_ids) . ")" . $where, " ORDER BY fi.field_order"); $to_emails = $to_email ? $to_email : array(); $plain_text = (isset($notification['plain_text']) and $notification['plain_text']) ? true : false; $custom_message = false; $mail_body = ''; if (isset($notification['email_message']) and trim($notification['email_message']) != '') { if (isset($notification['ar']) and $notification['ar']) { //don't continue with blank autoresponder message for reverse compatability if ($notification['email_message'] == '') { continue; } $notification['email_message'] = apply_filters('frm_ar_message', $notification['email_message'], array('entry' => $entry, 'form' => $form)); } $custom_message = true; $shortcodes = FrmProAppHelper::get_shortcodes($notification['email_message'], $entry->form_id); $mail_body = FrmProFieldsHelper::replace_shortcodes($notification['email_message'], $entry, $shortcodes); } $reply_to_name = $frm_blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); //default sender name $odd = true; $attachments = array(); foreach ($values as $value) { $field = isset($fields[$value->field_id]) ? $fields[$value->field_id] : false; $prev_val = maybe_unserialize($value->meta_value); if ($value->field_type == 'file') { global $frmdb; if ($field) { $file_options = $field->field_options; } else { $file_options = $frmdb->get_var($frmdb->fields, array('id' => $value->field_id), 'field_options'); } $file_options = maybe_unserialize($file_options); if (isset($file_options['attach']) and $file_options['attach']) { foreach ((array) $prev_val as $m) { $file = get_post_meta($m, '_wp_attached_file', true); if ($file) { if (!isset($uploads) or !isset($uploads['basedir'])) { $uploads = wp_upload_dir(); } $attachments[] = $uploads['basedir'] . "/{$file}"; } unset($m); } } unset($file_options); } $val = apply_filters('frm_email_value', $prev_val, $value, $entry); if ($value->field_type == 'textarea' and !$plain_text) { $val = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $val); } if (is_array($val)) { $val = implode(', ', $val); } if (isset($notification['reply_to']) and (int) $notification['reply_to'] == $value->field_id) { if ($value->field_type == 'user_id') { $user_data = get_userdata($value->meta_value); $reply_to = $user_data->user_email; } else { if (is_email($val)) { $reply_to = $val; } else { if (is_email($prev_val)) { $reply_to = $prev_val; } } } } if (isset($notification['reply_to_name']) and (int) $notification['reply_to_name'] == $value->field_id) { if ($value->field_type == 'user_id') { $user_data = get_userdata($value->meta_value); $reply_to_name = $user_data->display_name; } else { $reply_to_name = $val; } } if (in_array($value->field_id, $email_fields)) { if ($value->field_type == 'user_id') { $user_data = get_userdata($value->meta_value); $to_emails[] = $user_data->user_email; } else { $val = explode(',', $val); $prev_val = explode(',', $prev_val); if (is_array($val) or is_array($prev_val)) { foreach ((array) $val as $v) { $v = trim($v); if (is_email($v)) { $to_emails[] = $v; } unset($v); } foreach ((array) $prev_val as $v) { $v = trim($v); if (is_email($v) and !in_array($v, $to_emails)) { $to_emails[] = $v; } unset($v); } } else { if (is_email($val)) { $to_emails[] = $val; } else { if (is_email($prev_val)) { $to_emails[] = $prev_val; } } } } } } unset($prev_val); $attachments = apply_filters('frm_notification_attachment', $attachments, $form, array('entry' => $entry, 'email_key' => $email_key)); if (isset($notification['ar']) and $notification['ar']) { $attachments = apply_filters('frm_autoresponder_attachment', array(), $form); } if (!isset($reply_to)) { $reply_to = '[admin_email]'; } if ($notification['reply_to'] == 'custom') { $reply_to = isset($notification['cust_reply_to']) ? $notification['cust_reply_to'] : $reply_to; } if (empty($reply_to)) { $reply_to = '[admin_email]'; //global $frm_settings; //$reply_to = $frm_settings->email_to; } if ($notification['reply_to_name'] == 'custom') { $reply_to_name = isset($notification['cust_reply_to_name']) ? $notification['cust_reply_to_name'] : $reply_to_name; $reply_to_name = apply_filters('frm_content', $reply_to_name, $form, $entry_id); } $prev_mail_body = $mail_body; $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'fields' => $fields, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false)); if (isset($notification['inc_user_info']) && $notification['inc_user_info'] && $prev_mail_body == $mail_body) { $data = maybe_unserialize($entry->description); $mail_body .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n"; $mail_body .= __('IP Address', 'formidable') . ": " . $entry->ip . "\r\n"; $mail_body .= __('User-Agent (Browser/OS)', 'formidable') . ": " . $data['browser'] . "\r\n"; $mail_body .= __('Referrer', 'formidable') . ": " . $data['referrer'] . "\r\n"; } unset($prev_mail_body); if (isset($notification['email_subject']) and $notification['email_subject'] != '') { $shortcodes = FrmProAppHelper::get_shortcodes($notification['email_subject'], $entry->form_id); $subject = FrmProFieldsHelper::replace_shortcodes($notification['email_subject'], $entry, $shortcodes); $subject = apply_filters('frm_email_subject', $subject, compact('form', 'entry', 'email_key')); if (isset($notification['ar']) and $notification['ar']) { $subject = apply_filters('frm_ar_subject', $subject, $form); } } else { //set default subject $subject = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, $frm_blogname); } $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form_id, compact('email_key', 'entry')); $to_emails = array_unique((array) $to_emails); $sent = array(); foreach ((array) $to_emails as $to_email) { $to_email = apply_filters('frm_content', $to_email, $form, $entry_id); $to_email = do_shortcode($to_email); if (strpos($to_email, ',')) { $to_email = explode(',', $to_email); } foreach ((array) $to_email as $e) { $e = trim($e); if (($e == '[admin_email]' or is_email($e)) and !in_array($e, $sent)) { $sent_to[] = $sent[] = $e; $frm_notification->send_notification_email($e, $subject, $mail_body, $reply_to, $reply_to_name, $plain_text, $attachments); } else { if (!in_array($e, $sent)) { do_action('frm_send_to_not_email', compact('e', 'subject', 'mail_body', 'reply_to', 'reply_to_name', 'plain_text', 'attachments', 'form', 'email_key')); } } unset($e); } unset($to_email); } unset($sent, $to_emails, $notification, $subject, $mail_body); unset($reply_to, $reply_to_name, $plain_text, $attachments); } return $sent_to; }
public static function setup_edit_vars($record, $table, $fields = '', $default = false, $post_values = array()) { if (!$record) { return false; } global $frm_entry_meta, $frm_settings, $frm_vars; if (empty($post_values)) { $post_values = stripslashes_deep($_POST); } $values = array('id' => $record->id, 'fields' => array()); foreach (array('name', 'description') as $var) { $default_val = isset($record->{$var}) ? $record->{$var} : ''; $values[$var] = FrmAppHelper::get_param($var, $default_val); unset($var, $default_val); } if (apply_filters('frm_use_wpautop', true)) { $values['description'] = wpautop(str_replace('<br>', '<br />', $values['description'])); } foreach ((array) $fields as $field) { if ($default) { $meta_value = $field->default_value; } else { if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) { if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field)); } else { if (isset($record->metas)) { $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false; } else { $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id); } } } $field_type = isset($post_values['field_options']['type_' . $field->id]) ? $post_values['field_options']['type_' . $field->id] : $field->type; $new_value = isset($post_values['item_meta'][$field->id]) ? maybe_unserialize($post_values['item_meta'][$field->id]) : $meta_value; $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); /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){ foreach((array)$field_array['options'] as $opt_key => $opt){ if(!is_array($opt)) $field_array['options'][$opt_key] = array('label' => $opt); unset($opt); unset($opt_key); } }*/ $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); foreach ($opt_defaults as $opt => $default_opt) { $field_array[$opt] = $post_values && isset($post_values['field_options'][$opt . '_' . $field->id]) ? maybe_unserialize($post_values['field_options'][$opt . '_' . $field->id]) : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt); if ($opt == 'blank' and $field_array[$opt] == '') { $field_array[$opt] = $frm_settings->blank_msg; } else { if ($opt == 'invalid' and $field_array[$opt] == '') { if ($field_type == 'captcha') { $field_array[$opt] = $frm_settings->re_msg; } else { $field_array[$opt] = sprintf(__('%s is invalid', 'formidable'), $field_array['name']); } } } } unset($opt_defaults); if ($field_array['custom_html'] == '') { $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type); } if ($field_array['size'] == '') { $field_array['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : ''; } $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); if (!isset($field_array['unique']) or !$field_array['unique']) { $field_array['unique_msg'] = ''; } foreach ((array) $field->field_options as $k => $v) { if (!isset($field_array[$k])) { $field_array[$k] = $v; } unset($k); unset($v); } $values['fields'][$field->id] = $field_array; unset($field); } $frm_form = new FrmForm(); $form = $frm_form->getOne($table == 'entries' ? $record->form_id : $record->id); unset($frm_form); if ($form) { $values['form_name'] = isset($record->form_id) ? $form->name : ''; if (is_array($form->options)) { foreach ($form->options as $opt => $value) { if (in_array($opt, array('email_to', 'reply_to', 'reply_to_name'))) { $values['notification'][0][$opt] = isset($post_values["notification[0][{$opt}]"]) ? maybe_unserialize($post_values["notification[0][{$opt}]"]) : $value; } $values[$opt] = isset($post_values[$opt]) ? maybe_unserialize($post_values[$opt]) : $value; } } } $form_defaults = FrmFormsHelper::get_default_opts(); //set to posted value or default foreach ($form_defaults as $opt => $default) { if (!isset($values[$opt]) or $values[$opt] == '') { if ($opt == 'notification') { $values[$opt] = ($post_values and isset($post_values[$opt])) ? $post_values[$opt] : $default; foreach ($default as $o => $d) { if ($o == 'email_to') { $d = ''; } //allow blank email address $values[$opt][0][$o] = ($post_values and isset($post_values[$opt][0][$o])) ? $post_values[$opt][0][$o] : $d; unset($o); unset($d); } } else { $values[$opt] = ($post_values and isset($post_values['options'][$opt])) ? $post_values['options'][$opt] : $default; } } else { if ($values[$opt] == 'notification') { foreach ($values[$opt] as $k => $n) { foreach ($default as $o => $d) { if (!isset($n[$o])) { $values[$opt][$k][$o] = ($post_values and isset($post_values[$opt][$k][$o])) ? $post_values[$opt][$k][$o] : $d; } unset($o); unset($d); } unset($k); unset($n); } } } unset($opt); unset($defaut); } if (!isset($values['custom_style'])) { $values['custom_style'] = ($post_values and isset($post_values['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none'; } foreach (array('before', 'after', 'submit') as $h) { if (!isset($values[$h . '_html'])) { $values[$h . '_html'] = isset($post_values['options'][$h . '_html']) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html($h); } unset($h); } if ($table == 'entries') { $values = FrmEntriesHelper::setup_edit_vars($values, $record); } else { if ($table == 'forms') { $values = FrmFormsHelper::setup_edit_vars($values, $record, $post_values); } } return $values; }
function ajax_data_options($hide_field, $entry_id, $selected_field_id, $field_id) { global $frmpro_entry_meta, $frm_field; $data_field = $frm_field->getOne($selected_field_id); $entry_id = explode(',', $entry_id); $field_name = "item_meta[{$field_id}]"; $field_data = $frm_field->getOne($field_id); $field_data->field_options = maybe_unserialize($field_data->field_options); $field = array('id' => $field_id, 'value' => '', 'default_value' => '', 'form_id' => $field_data->form_id, 'type' => apply_filters('frm_field_type', $field_data->type, $field_data, ''), 'options' => stripslashes_deep(maybe_unserialize($field_data->options)), 'size' => isset($field_data->field_options['size']) && $field_data->field_options['size'] != '' ? $field_data->field_options['size'] : ''); if ($field['size'] == '') { global $frm_sidebar_width; $field['size'] = $frm_sidebar_width; } $field = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field), $field_data); if (is_numeric($selected_field_id)) { $field['options'] = array(); $metas = $frmpro_entry_meta->meta_through_join($hide_field, $data_field, $entry_id); foreach ($metas as $meta) { $field['options'][$meta->item_id] = FrmProEntryMetaHelper::display_value($meta->meta_value, $data_field, array('type' => $data_field->type, 'show_icon' => true, 'show_filename' => false)); } } else { if ($selected_field_id == 'taxonomy') { $cat_ids = array_keys($field['options']); $args = array('include' => implode(',', $cat_ids), 'hide_empty' => false); if (function_exists('get_object_taxonomies')) { $post_type = FrmProForm::post_type($field_data->form_id); $args['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $field_data); if (!$args['taxonomy']) { return; } } $cats = get_categories($args); foreach ($cats as $cat) { if (!in_array($cat->parent, (array) $entry_id)) { unset($field['options'][$cat->term_id]); } } } } $auto_width = isset($field['size']) && $field['size'] > 0 ? 'class="auto_width"' : ''; require FRMPRO_VIEWS_PATH . '/frmpro-fields/data-options.php'; die; }
function get_max($field) { _deprecated_function(__FUNCTION__, '1.07.05', 'FrmProEntryMetaHelper::get_max'); return FrmProEntryMetaHelper::get_max($field); }
public static function add_repeating_value_to_entry($field, &$entry) { // If field is in a repeating section if ($entry->form_id != $field->form_id) { // get entry ids linked through repeat field or embeded form $child_entries = FrmProEntry::get_sub_entries($entry->id, true); $val = FrmProEntryMetaHelper::get_sub_meta_values($child_entries, $field); if (!empty($val)) { //Flatten multi-dimensional arrays if (is_array($val)) { $val = FrmAppHelper::array_flatten($val); } $entry->metas[$field->id] = $val; } } else { $val = ''; FrmProEntriesHelper::get_dynamic_list_values($field, $entry, $val); $entry->metas[$field->id] = $val; } }
/** * Don't require a dynamic field that has no options * @since 2.0 */ public static function is_dynamic_field_empty(&$field, $key, $hide_field, $observed_value) { // Get the field that conditional logic is dependent on $observed_field = FrmField::getOne($hide_field); // Leave now if conditional logic field is not a Dynamic field if ($observed_field->type != 'data') { return; } // Check if current posted value is set for conditional logic checking if (empty($field->field_options['hide_opt'][$key])) { $field->field_options['hide_opt'][$key] = $observed_value; // If logic is 'Dynamic parent is equal to anything' and no value // is set in parent field, make sure logic doesn't return true if (empty($observed_value) && $field->field_options['hide_field_cond'][$key] == '==') { $field->field_options['hide_opt'][$key] = 'anything'; return; } else { if ($field->field_options['data_type'] == 'data') { return; } } } // Get linked field data $selected_field_id = isset($field->field_options['form_select']) ? $field->field_options['form_select'] : ''; if ($selected_field_id == 'taxonomy') { self::update_dynamic_category_field_if_empty($field, $key); return; } $data_field = FrmField::getOne($selected_field_id); // Get value from previous Dynamic field $parent_val = $field->field_options['hide_opt'][$key]; // Makes sure this works with multi-select and non multi-select fields if (!is_array($parent_val)) { $parent_val = explode(',', $parent_val); } // If this is a regular dynamic field $metas = array(); FrmProEntryMetaHelper::meta_through_join($hide_field, $data_field, $parent_val, $field, $metas); if (empty($metas)) { // indicate that this field is hidden $field->field_options['hide_opt'][$key] = ''; } $field->field_options['hide_opt'][$key] = apply_filters('frm_is_dynamic_field_empty', $field->field_options['hide_opt'][$key], compact('field', 'key', 'hide_field', 'observed_value')); }
public static function ajax_data_options() { $hide_field = FrmAppHelper::get_param('hide_field'); $entry_id = FrmAppHelper::get_param('entry_id'); $selected_field_id = FrmAppHelper::get_param('selected_field_id'); $field_id = FrmAppHelper::get_param('field_id'); global $frm_field; $data_field = $frm_field->getOne($selected_field_id); if ($entry_id == '') { die; } $entry_id = explode(',', $entry_id); $field_data = $frm_field->getOne($field_id); $field_name = "item_meta[{$field_id}]"; if (isset($field_data->field_options['multiple']) and $field_data->field_options['multiple'] and ($field_data->type == 'select' or $field_data->type == 'data' and isset($field_data->field_options['data_type']) and $field_data->field_options['data_type'] == 'select')) { $field_name .= '[]'; } $field = array('id' => $field_id, 'value' => '', 'default_value' => '', 'form_id' => $field_data->form_id, 'type' => apply_filters('frm_field_type', $field_data->type, $field_data, ''), 'options' => $field_data->options, 'size' => isset($field_data->field_options['size']) && $field_data->field_options['size'] != '' ? $field_data->field_options['size'] : '', 'field_key' => $field_data->field_key); if ($field['size'] == '') { global $frm_vars; $field['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : ''; } if (is_numeric($selected_field_id)) { $field['options'] = array(); $metas = FrmProEntryMetaHelper::meta_through_join($hide_field, $data_field, $entry_id); $metas = stripslashes_deep($metas); if ($metas and (!isset($field_data->field_options['data_type']) or !in_array($field_data->field_options['data_type'], array('radio', 'checkbox'))) and (!isset($field_data->field_options['multiple']) or !$field_data->field_options['multiple'] or isset($field_data->field_options['autocom']) and $field_data->field_options['autocom'])) { $field['options'][''] = ''; } foreach ($metas as $meta) { $field['options'][$meta->item_id] = FrmProEntryMetaHelper::display_value($meta->meta_value, $data_field, array('type' => $data_field->type, 'show_icon' => true, 'show_filename' => false)); unset($meta); } $field = apply_filters('frm_setup_new_fields_vars', $field, $field_data); } else { if ($selected_field_id == 'taxonomy') { if ($entry_id == 0) { die; } if (is_array($entry_id)) { $zero = array_search(0, $entry_id); if ($zero !== false) { unset($entry_id[$zero]); } if (empty($entry_id)) { die; } } $field = apply_filters('frm_setup_new_fields_vars', $field, $field_data); $cat_ids = array_keys($field['options']); $args = array('include' => implode(',', $cat_ids), 'hide_empty' => false); $post_type = FrmProFormsHelper::post_type($field_data->form_id); $args['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $field_data); if (!$args['taxonomy']) { die; } $cats = get_categories($args); foreach ($cats as $cat) { if (!in_array($cat->parent, (array) $entry_id)) { unset($field['options'][$cat->term_id]); } } if (count($field['options']) == 1 and reset($field['options']) == '') { die; } } else { $field = apply_filters('frm_setup_new_fields_vars', $field, $field_data); } } $auto_width = isset($field['size']) && $field['size'] > 0 ? 'class="auto_width"' : ''; require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/data-options.php'; die; }
function get_post_or_meta_value($entry, $field, $atts = array()) { global $frm_entry_meta; if (!is_object($entry)) { global $frm_entry; $entry = $frm_entry->getOne($entry); } $field->field_options = maybe_unserialize($field->field_options); if ($entry->post_id) { if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } $links = true; if (isset($atts['links'])) { $links = $atts['links']; } if ($field->type == 'tag' or $field->field_options['post_field']) { $post_args = array('type' => $field->type, 'form_id' => $field->form_id, 'field' => $field, 'links' => $links, 'exclude_cat' => $field->field_options['exclude_cat']); if (isset($atts['show'])) { $post_args['show'] = $atts['show']; } $value = FrmProEntryMetaHelper::get_post_value($entry->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], $post_args); unset($post_args); } else { $value = $frm_entry_meta->get_entry_meta_by_field($entry->id, $field->id); } } else { $value = $frm_entry_meta->get_entry_meta_by_field($entry->id, $field->id); } return $value; }
echo $field->name; ?> :</th> <td> <?php $field_value = isset($entry->metas[$field->id]) ? $entry->metas[$field->id] : false; $field->field_options = maybe_unserialize($field->field_options); if (!$field_value and $field->type == 'data' and $field->field_options['data_type'] == 'data' and isset($field->field_options['hide_field'])) { $field_value = array(); foreach ((array) $field->field_options['hide_field'] as $hfield) { if (isset($entry->metas[$hfield])) { $field_value[] = maybe_unserialize($entry->metas[$hfield]); } } } echo $display_value = FrmProEntryMetaHelper::display_value($field_value, $field, array('type' => $field->type, 'post_id' => $entry->post_id, 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id)); if (is_email($display_value) and !in_array($display_value, $to_emails)) { $to_emails[] = $display_value; } ?> </td> </tr> <?php } } ?> <?php if ($entry->post_id) { ?> <tr><th><?php _e('Post', 'formidable');
function setup_edit_vars($record, $table, $fields = '', $default = false) { if (!$record) { return false; } global $frm_entry_meta, $frm_form, $frm_settings, $frm_sidebar_width; $values = array(); $values['id'] = $record->id; foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val) { $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default_val)); } if (apply_filters('frm_use_wpautop', true)) { $values['description'] = wpautop($values['description']); } $values['fields'] = array(); if ($fields) { foreach ($fields as $field) { $field->field_options = stripslashes_deep(maybe_unserialize($field->field_options)); if ($default) { $meta_value = $field->default_value; } else { if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) { $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field)); } else { if (isset($record->metas)) { $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false; } else { $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id); } } } $field_type = isset($_POST['field_options']['type_' . $field->id]) ? $_POST['field_options']['type_' . $field->id] : $field->type; $new_value = isset($_POST['item_meta'][$field->id]) ? $_POST['item_meta'][$field->id] : $meta_value; $new_value = maybe_unserialize($new_value); if (is_array($new_value)) { $new_value = stripslashes_deep($new_value); } $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => stripslashes_deep(maybe_unserialize($field->default_value)), 'name' => stripslashes($field->name), 'description' => stripslashes($field->description), 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => stripslashes_deep(maybe_unserialize($field->options)), 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id); /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){ foreach((array)$field_array['options'] as $opt_key => $opt){ if(!is_array($opt)) $field_array['options'][$opt_key] = array('label' => $opt); unset($opt); unset($opt_key); } }*/ $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); foreach ($opt_defaults as $opt => $default_opt) { $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt . '_' . $field->id])) ? $_POST['field_options'][$opt . '_' . $field->id] : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt); if ($opt == 'blank' and $field_array[$opt] == '') { $field_array[$opt] = __('This field cannot be blank', 'formidable'); } else { if ($opt == 'invalid' and $field_array[$opt] == '') { if ($field_type == 'captcha') { $field_array[$opt] = $frm_settings->re_msg; } else { $field_array[$opt] = $field_array['name'] . ' ' . __('is invalid', 'formidable'); } } } } unset($opt_defaults); if ($field_array['custom_html'] == '') { $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type); } if ($field_array['size'] == '') { $field_array['size'] = $frm_sidebar_width; } $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']); unset($field); } } if ($table == 'entries') { $form = $frm_form->getOne($record->form_id); } else { if ($table == 'forms') { $form = $frm_form->getOne($record->id); } } if ($form) { $form->options = maybe_unserialize($form->options); $values['form_name'] = isset($record->form_id) ? $form->name : ''; if (is_array($form->options)) { foreach ($form->options as $opt => $value) { $values[$opt] = FrmAppHelper::get_param($opt, $value); } } } $form_defaults = FrmFormsHelper::get_default_opts(); $form_defaults['email_to'] = ''; //options to allow blank answers foreach (array('email_to', 'reply_to', 'reply_to_name') as $opt) { if (!isset($values[$opt])) { $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $form_defaults[$opt]; unset($form_defaults[$opt]); unset($opt); } } //don't allow blank answers foreach ($form_defaults as $opt => $default) { if (!isset($values[$opt]) or $values[$opt] == '') { $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $default; } unset($opt); unset($defaut); } if (!isset($values['custom_style'])) { $values['custom_style'] = ($_POST and isset($_POST['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none'; } if (!isset($values['before_html'])) { $values['before_html'] = isset($_POST['options']['before_html']) ? $_POST['options']['before_html'] : FrmFormsHelper::get_default_html('before'); } if (!isset($values['after_html'])) { $values['after_html'] = isset($_POST['options']['after_html']) ? $_POST['options']['after_html'] : FrmFormsHelper::get_default_html('after'); } if ($table == 'entries') { $values = FrmEntriesHelper::setup_edit_vars($values, $record); } else { if ($table == 'forms') { $values = FrmFormsHelper::setup_edit_vars($values, $record); } } return $values; }
public static function email_value($value, $meta, $entry) { return FrmProEntryMetaHelper::email_value($value, $meta, $entry); }
/** * Get the value from a specific field and entry * * @since 2.01.02 * @param object $entry * @param int $field_id * @return array|bool|mixed|string */ private static function get_value_from_entry($entry, $field_id) { $observed_value = ''; if (isset($entry->metas[$field_id])) { $observed_value = $entry->metas[$field_id]; } else { if ($entry->post_id && FrmAppHelper::pro_is_installed()) { $field = FrmField::getOne($field_id); $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, array('links' => false, 'truncate' => false)); } } return $observed_value; }
public static function replace_shortcodes($content, $entry, $shortcodes, $display = false, $show = 'one', $odd = '', $args = array()) { global $frm_field, $frm_entry_meta, $post, $frmpro_settings; if ($display) { $param_value = $display->frm_type == 'id' ? $entry->id : $entry->item_key; if ($entry->post_id) { $detail_link = get_permalink($entry->post_id); } else { $param = isset($display->frm_param) && !empty($display->frm_param) ? $display->frm_param : 'entry'; if ($post) { $detail_link = add_query_arg($param, $param_value, get_permalink($post->ID)); } else { $detail_link = add_query_arg($param, $param_value); } //if( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // $detail_link = get_permalink($post->ID) .$param_value .'/'; } } foreach ($shortcodes[0] as $short_key => $tag) { $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false; $atts = shortcode_parse_atts($shortcodes[3][$short_key]); if (!empty($shortcodes[3][$short_key])) { $tag = str_replace($conditional ? '[if ' : '[', '', $shortcodes[0][$short_key]); $tag = str_replace(']', '', $tag); $tags = explode(' ', $tag); if (is_array($tags)) { $tag = $tags[0]; } } else { $tag = $shortcodes[2][$short_key]; } switch ($tag) { case 'entry_count': $content = str_replace($shortcodes[0][$short_key], isset($args['record_count']) ? $args['record_count'] : '', $content); break; case 'detaillink': if ($display and $detail_link) { $content = str_replace($shortcodes[0][$short_key], $detail_link, $content); } break; case 'id': $content = str_replace($shortcodes[0][$short_key], $entry->id, $content); break; case 'post-id': case 'post_id': $content = str_replace($shortcodes[0][$short_key], $entry->post_id, $content); break; case 'key': $content = str_replace($shortcodes[0][$short_key], $entry->item_key, $content); break; case 'ip': $content = str_replace($shortcodes[0][$short_key], $entry->ip, $content); break; case 'user_agent': case 'user-agent': $entry->description = maybe_unserialize($entry->description); $content = str_replace($shortcodes[0][$short_key], $entry->description['browser'], $content); break; case 'created_at': case 'created-at': case 'updated_at': case 'updated-at': if (!isset($atts['format'])) { $atts['format'] = get_option('date_format'); $time_format = false; } else { $time_format = ' '; } $this_tag = str_replace('-', '_', $tag); if ($conditional) { $atts['short_key'] = $shortcodes[0][$short_key]; $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag); } else { if (isset($atts['time_ago'])) { $date = FrmProAppHelper::human_time_diff(strtotime($entry->{$this_tag})); } else { $date = FrmProAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); } $content = str_replace($shortcodes[0][$short_key], $date, $content); } unset($this_tag); break; case 'created_by': case 'created-by': case 'updated_by': case 'updated-by': $this_tag = str_replace('-', '_', $tag); $replace_with = self::get_display_value($entry->{$this_tag}, (object) array('type' => 'user_id'), $atts); if ($conditional) { $atts['short_key'] = $shortcodes[0][$short_key]; $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag); } else { $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($this_tag); unset($replace_with); break; case 'evenodd': $content = str_replace($shortcodes[0][$short_key], $odd, $content); break; case 'siteurl': $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::site_url(), $content); break; case 'frmurl': $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::plugin_url(), $content); break; case 'sitename': $content = str_replace($shortcodes[0][$short_key], get_option('blogname'), $content); break; case 'get': if (isset($atts['param'])) { $param = $atts['param']; $replace_with = FrmAppHelper::get_param($param); if (is_array($replace_with)) { $replace_with = implode(', ', $replace_with); } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); unset($param); unset($replace_with); } break; default: if ($tag == 'deletelink') { $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0); if (!isset($atts['label'])) { $atts['label'] = false; } $delete_atts = $atts; $delete_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_delete_link($delete_atts); unset($delete_atts); $field = false; } else { if ($tag == 'editlink') { $replace_with = ''; $link_text = isset($atts['label']) ? $atts['label'] : false; if (!$link_text) { $link_text = isset($atts['link_text']) ? $atts['link_text'] : __('Edit'); } $class = isset($atts['class']) ? $atts['class'] : ''; $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0); if (isset($atts['location']) && $atts['location'] == 'front' || isset($atts['prefix']) && !empty($atts['prefix']) || isset($atts['page_id']) && !empty($atts['page_id'])) { $edit_atts = $atts; $edit_atts['id'] = $entry->id; $delete_atts['page_id'] = $page_id; $replace_with = FrmProEntriesController::entry_edit_link($edit_atts); } else { if ($entry->post_id) { $replace_with = get_edit_post_link($entry->post_id); } else { if (current_user_can('frm_edit_entries')) { $replace_with = esc_url(admin_url('admin.php?page=formidable-entries&frm_action=edit&id=' . $entry->id)); } } if (!empty($replace_with)) { $replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>'; } } unset($class); } else { $field = $frm_field->getOne($tag); } } $sep = isset($atts['sep']) ? $atts['sep'] : ', '; if (!isset($field)) { $field = false; } if ($field) { $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts); $atts['entry_id'] = $entry->id; $atts['entry_key'] = $entry->item_key; $atts['post_id'] = $entry->post_id; $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field); } if ($field and $field->type == 'file') { //size options are thumbnail, medium, large, or full, label $size = isset($atts['size']) ? $atts['size'] : (isset($atts['show']) ? $atts['show'] : 'thumbnail'); $inc_html = (isset($atts['html']) and $atts['html']) ? true : false; $inc_links = (isset($atts['links']) and $atts['links']) ? true : false; $sep = isset($atts['sep']) ? $atts['sep'] : ' '; $show_filename = (isset($atts['show_filename']) and $atts['show_filename']) ? true : false; if ($size != 'id' && !empty($replace_with)) { $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size, array('html' => $inc_html, 'links' => $inc_links, 'show_filename' => $show_filename)); } else { if (is_array($replace_with)) { $replace_with = array_filter($replace_with); } } unset($size); } if (isset($replace_with) and is_array($replace_with)) { $replace_with = implode($sep, $replace_with); } if ($conditional) { if (!isset($replace_with)) { $replace_with = ''; } $replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag); $start_pos = strpos($content, $shortcodes[0][$short_key]); if ($start_pos !== false) { $start_pos_len = strlen($shortcodes[0][$short_key]); $end_pos = strpos($content, '[/if ' . $tag . ']', $start_pos); $end_pos_len = strlen('[/if ' . $tag . ']'); if ($end_pos !== false) { if (empty($replace_with)) { $total_len = $end_pos + $end_pos_len - $start_pos; $content = substr_replace($content, '', $start_pos, $total_len); } else { $content = substr_replace($content, '', $end_pos, $end_pos_len); $content = substr_replace($content, '', $start_pos, $start_pos_len); } } } } else { if ($field) { if (isset($atts['show']) and $atts['show'] == 'field_label') { $replace_with = $field->name; } else { if (isset($atts['show']) and $atts['show'] == 'description') { $replace_with = $field->description; } else { if (empty($replace_with) and $replace_with != '0') { $replace_with = ''; if ($field->type == 'number') { $replace_with = '0'; } } else { $replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts); } } } } if (isset($atts['sanitize'])) { $replace_with = sanitize_title_with_dashes($replace_with); } if (isset($atts['sanitize_url'])) { if (seems_utf8($replace_with)) { $replace_with = utf8_uri_encode($replace_with, 200); } $replace_with = urlencode(htmlentities($replace_with)); } if (isset($atts['truncate'])) { if (isset($atts['more_text'])) { $more_link_text = $atts['more_text']; } else { $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .'; } if ($display and $display->frm_show_count == 'dynamic') { $more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>'; $replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text); } else { $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES); $part_one = substr($replace_with, 0, (int) $atts['truncate']); $part_two = substr($replace_with, (int) $atts['truncate']); if (!empty($part_two)) { $replace_with = $part_one . '<a href="#" onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\');return false;" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>'; } } } if (isset($atts['clickable'])) { $replace_with = make_clickable($replace_with); } if (!isset($replace_with)) { $replace_with = ''; } $content = str_replace($shortcodes[0][$short_key], $replace_with, $content); } unset($replace_with); if (isset($field)) { unset($field); } } unset($atts); unset($conditional); } return $content; }
function build_calendar($new_content, $entries, $shortcodes, $display, $show = 'one') { if (!$display or $display->show_count != 'calendar') { return $new_content; } global $frm_entry_meta, $wp_locale; $display_options = maybe_unserialize($display->options); $current_year = date_i18n('Y'); $current_month = date_i18n('n'); $year = FrmAppHelper::get_param('frmcal-year', date('Y')); //4 digit year $month = FrmAppHelper::get_param('frmcal-month', $current_month); //Numeric month without leading zeros $timestamp = mktime(0, 0, 0, $month, 1, $year); $maxday = date('t', $timestamp); //Number of days in the given month $this_month = getdate($timestamp); $startday = $this_month['wday']; if ($current_year == $year and $current_month == $month) { $today = date_i18n('j'); } $cal_end = $maxday + $startday; $t = $cal_end > 35 ? 42 : ($cal_end == 28 ? 28 : 35); $extrarows = $t - $maxday - $startday; $show_entres = false; $daily_entries = array(); if (isset($display_options['date_field_id']) and is_numeric($display_options['date_field_id'])) { $field = FrmField::getOne($display_options['date_field_id']); } if (isset($display_options['edate_field_id']) and is_numeric($display_options['edate_field_id'])) { $efield = FrmField::getOne($display_options['edate_field_id']); } else { $efield = false; } foreach ($entries as $entry) { if (isset($display_options['date_field_id']) and is_numeric($display_options['date_field_id'])) { if (isset($entry->metas)) { $date = isset($entry->metas[$display_options['date_field_id']]) ? $entry->metas[$display_options['date_field_id']] : false; } else { $date = $frm_entry_meta->get_entry_meta_by_field($entry->id, $display_options['date_field_id']); } if ($entry->post_id and !$date) { if ($field) { $field->field_options = maybe_unserialize($field->field_options); if ($field->field_options['post_field']) { $date = FrmProEntryMetaHelper::get_post_value($entry->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('form_id' => $display->form_id, 'type' => $field->type, 'field' => $field)); } } } } else { if ($display_options['date_field_id'] == 'updated_at') { $date = $entry->updated_at; $i18n = true; } else { $date = $entry->created_at; $i18n = true; } } if (empty($date)) { continue; } if (isset($il8n) and $il8n) { $date = date_i18n('Y-m-d', strtotime($date)); } else { $date = date('Y-m-d', strtotime($date)); } unset($i18n); $dates = array($date); if (isset($display_options['edate_field_id']) and !empty($display_options['edate_field_id'])) { if (is_numeric($display_options['edate_field_id']) and $efield) { $edate = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $efield); if ($efield and $efield->type == 'number' and is_numeric($edate)) { $edate = date('Y-m-d', strtotime('+' . $edate . ' days', strtotime($date))); } } else { if ($display_options['edate_field_id'] == 'updated_at') { $edate = date_i18n('Y-m-d', strtotime($entry->updated_at)); } else { $edate = date_i18n('Y-m-d', strtotime($entry->created_at)); } } if ($edate and !empty($edate)) { $from_date = strtotime($date); $to_date = strtotime($edate); if (!empty($from_date) and $from_date < $to_date) { for ($current_ts = $from_date; $current_ts <= $to_date; $current_ts += 60 * 60 * 24) { $dates[] = date('Y-m-d', $current_ts); } unset($current_ts); } unset($from_date); unset($to_date); } unset($edate); $used_entries = array(); } unset($date); $dates = apply_filters('frm_show_entry_dates', $dates, $entry); for ($i = 0; $i < $maxday + $startday; $i++) { $day = $i - $startday + 1; if (in_array(date('Y-m-d', strtotime("{$year}-{$month}-{$day}")), $dates)) { $show_entres = true; $daily_entres[$i][] = $entry; } unset($day); } unset($dates); } $day_names = $wp_locale->weekday_abbrev; $day_names = FrmProAppHelper::reset_keys($day_names); //switch keys to order ob_start(); include FRMPRO_VIEWS_PATH . '/displays/calendar.php'; $content = ob_get_contents(); ob_end_clean(); return $content; }
header('Content-Type: text/csv; charset=' . $charset, true); header('Expires: ' . gmdate("D, d M Y H:i:s", mktime(date('H') + 2, date('i'), date('s'), date('m'), date('d'), date('Y'))) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); foreach ($form_cols as $col) { echo '"' . FrmProEntriesHelper::encode_value(strip_tags($col->name), $charset, $to_encoding) . '",'; } echo '"' . __('Timestamp', 'formidable') . '","IP","ID","Key"' . "\n"; foreach ($entries as $entry) { foreach ($form_cols as $col) { $field_value = isset($entry->metas[$col->id]) ? $entry->metas[$col->id] : false; if (!$field_value and $entry->post_id) { $col->field_options = maybe_unserialize($col->field_options); if (isset($col->field_options['post_field']) and $col->field_options['post_field']) { $field_value = FrmProEntryMetaHelper::get_post_value($entry->post_id, $col->field_options['post_field'], $col->field_options['custom_field'], array('truncate' => $col->field_options['post_field'] == 'post_category' ? true : false, 'form_id' => $entry->form_id, 'field' => $col, 'type' => $col->type, 'exclude_cat' => isset($col->field_options['exclude_cat']) ? $col->field_options['exclude_cat'] : 0)); } } if ($col->type == 'user_id') { $field_value = FrmProFieldsHelper::get_display_name($field_value); } else { if ($col->type == 'file') { $field_value = FrmProFieldsHelper::get_file_name($field_value); } else { if ($col->type == 'date') { $field_value = FrmProFieldsHelper::get_date($field_value, $wp_date_format); } else { if ($col->type == 'data' && is_numeric($field_value)) { $field_value = FrmProFieldsHelper::get_data_value($field_value, $col); //replace entry id with specified field } else {
$col->options = maybe_unserialize($col->options); $count = count($col->options); if ($col->type == 'select' and reset($col->options) == '') { $col->field_options = maybe_unserialize($col->field_options); if ($col->field_options['post_field'] == 'post_status') { $count = 3; } else { $count--; } } if ($count == 1) { $type = 'boolean'; } unset($count); } $val = FrmProEntryMetaHelper::display_value(isset($entry->metas[$col->id]) ? $entry->metas[$col->id] : false, $col, array('type' => $col->type, 'post_id' => $entry->post_id, 'entry_id' => $entry->id, 'show_filename' => false)); if ($type == 'number') { ?> data.setCell(<?php echo $i; ?> ,<?php echo $c; ?> ,<?php echo empty($val) ? '0' : $val; ?> ); <?php } else { if ($type == 'boolean') {
public static function email_value($value, $meta, $entry) { _deprecated_function(__FUNCTION__, '2.0', 'FrmProEntryMetaHelper::email_value'); return FrmProEntryMetaHelper::email_value($value, $meta, $entry); }
/** * Prepare the saved value for display * @return string */ public static function display_value($value, $field, $atts = array()) { $defaults = array('type' => '', 'html' => false, 'show_filename' => true, 'truncate' => false, 'sep' => ', ', 'post_id' => 0, 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, 'return_array' => false); $atts = wp_parse_args($atts, $defaults); $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); if (!isset($field->field_options['post_field'])) { $field->field_options['post_field'] = ''; } if (!isset($field->field_options['custom_field'])) { $field->field_options['custom_field'] = ''; } if (FrmAppHelper::pro_is_installed() && $atts['post_id'] && ($field->field_options['post_field'] || $atts['type'] == 'tag')) { $atts['pre_truncate'] = $atts['truncate']; $atts['truncate'] = true; $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); $atts['truncate'] = $atts['pre_truncate']; } if ($value == '') { return $value; } $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); $value = apply_filters('frm_display_' . $field->type . '_value_custom', $value, compact('field', 'atts')); $new_value = ''; if (is_array($value) && $atts['type'] != 'file') { foreach ($value as $val) { if (is_array($val)) { //TODO: add options for display (li or ,) $new_value .= implode($atts['sep'], $val); if ($atts['type'] != 'data') { $new_value .= '<br/>'; } } unset($val); } } if (!empty($new_value)) { $value = $new_value; } else { if (is_array($value) && $atts['type'] != 'file' && !$atts['return_array']) { $value = implode($atts['sep'], $value); } } if ($atts['truncate'] && $atts['type'] != 'image') { $value = FrmAppHelper::truncate($value, 50); } if (!$atts['keepjs'] && !is_array($value)) { $value = wp_kses_post($value); } return apply_filters('frm_display_value', $value, $field, $atts); }
private static function add_field_values_to_csv(&$row) { foreach (self::$fields as $col) { $field_value = isset(self::$entry->metas[$col->id]) ? self::$entry->metas[$col->id] : false; // Post values need to be retrieved differently if (self::$entry->post_id && ($col->type == 'tag' || isset($col->field_options['post_field']) && $col->field_options['post_field'])) { $field_value = FrmProEntryMetaHelper::get_post_value(self::$entry->post_id, $col->field_options['post_field'], $col->field_options['custom_field'], array('truncate' => $col->field_options['post_field'] == 'post_category' ? true : false, 'form_id' => self::$entry->form_id, 'field' => $col, 'type' => $col->type, 'exclude_cat' => isset($col->field_options['exclude_cat']) ? $col->field_options['exclude_cat'] : 0, 'sep' => self::$separator)); } if (in_array($col->type, array('user_id', 'file', 'date', 'data'))) { $field_value = FrmProFieldsHelper::get_export_val($field_value, $col, self::$entry); } else { if (isset($col->field_options['separate_value']) && $col->field_options['separate_value']) { $sep_value = FrmEntriesHelper::display_value($field_value, $col, array('type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, 'entry_id' => self::$entry->id, 'sep' => self::$separator, 'embedded_field_id' => isset(self::$entry->embedded_fields) && isset(self::$entry->embedded_fields[$entry->id]) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0)); $row[$col->id . '_label'] = $sep_value; unset($sep_value); } $field_value = maybe_unserialize($field_value); $field_value = apply_filters('frm_csv_value', $field_value, array('field' => $col)); } $row[$col->id] = $field_value; unset($col, $field_value); } }