public function prepare_items() { global $wpdb, $per_page; $per_page = $this->get_items_per_page('formidable_page_formidable_entries_per_page'); $form_id = $this->params['form']; if (!$form_id) { $this->items = array(); $this->set_pagination_args(array('total_items' => 0, 'per_page' => $per_page)); return; } $default_orderby = 'id'; $default_order = 'DESC'; $s_query = array('it.form_id' => $form_id); $s = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : ''; if ($s != '' && FrmAppHelper::pro_is_installed()) { $fid = isset($_REQUEST['fid']) ? sanitize_title($_REQUEST['fid']) : ''; $s_query = FrmProEntriesHelper::get_search_str($s_query, $s, $form_id, $fid); } $orderby = isset($_REQUEST['orderby']) ? sanitize_title($_REQUEST['orderby']) : $default_orderby; if (strpos($orderby, 'meta') !== false) { $order_field_type = FrmField::get_type(str_replace('meta_', '', $orderby)); $orderby .= in_array($order_field_type, array('number', 'scale')) ? ' +0 ' : ''; } $order = isset($_REQUEST['order']) ? sanitize_title($_REQUEST['order']) : $default_order; $order = ' ORDER BY ' . $orderby . ' ' . $order; $page = $this->get_pagenum(); $start = (int) isset($_REQUEST['start']) ? absint($_REQUEST['start']) : ($page - 1) * $per_page; $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false); $total_items = FrmEntry::getRecordCount($s_query); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page)); }
public function is_new_entry($entry) { _deprecated_function(__FUNCTION__, '1.07.05', 'FrmProEntriesController::is_new_entry'); return FrmProEntriesHelper::is_new_entry($entry); }
<a href="<?php echo esc_url(add_query_arg(array('frm_action' => 'edit', 'entry' => $entry->id), $atts['permalink']) . $atts['anchor']); ?> "><?php echo $atts['edit_link']; ?> </a><?php } ?> </td> <?php } if ($atts['delete_link']) { ?> <td><?php if (FrmProEntriesHelper::user_can_delete($entry)) { ?> <a href="<?php echo esc_url(add_query_arg(array('frm_action' => 'destroy', 'entry' => $entry->id))); ?> " class="frm_delete_link" data-frmconfirm="'<?php echo esc_attr($atts['confirm']); ?> "><?php echo $atts['delete_link']; ?> </a><?php } ?> </td> <?php
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; }
public static function get_field($field = 'is_draft', $id) { _deprecated_function(__FUNCTION__, '2.0', 'FrmProEntriesHelper::get_field'); return FrmProEntriesHelper::get_field($field, $id); }
?> ,<?php echo $c; ?> ,'<a href="<?php echo esc_url(add_query_arg(array('frm_action' => 'edit', 'entry' => $entry->id), $permalink) . $anchor); ?> "><?php echo addslashes($edit_link); ?> </a>'); <?php } $c++; } if ($delete_link && FrmProEntriesHelper::user_can_delete($entry)) { ?> data.setCell(<?php echo $i; ?> ,<?php echo $c; ?> ,'<a href="<?php echo esc_url(add_query_arg(array('frm_action' => 'destroy', 'entry' => $entry->id))); ?> " class="frm_delete_link" onclick="return confirm(\'<?php echo esc_attr($confirm); ?> \')"><?php echo addslashes($delete_link);
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; } }
public static function get_dfe_values($field, $entry, &$field_value) { _deprecated_function(__FUNCTION__, '2.0.08', 'FrmProEntriesHelper::get_dynamic_list_values'); return FrmProEntriesHelper::get_dynamic_list_values($field, $entry, $field_value); }
public static function get_display_data($display, $content = '', $entry_id = false, $extra_atts = array()) { global $frmpro_display, $frm_entry, $frmpro_settings, $frm_entry_meta, $frm_vars, $post; $frm_vars['forms_loaded'][] = true; if (!isset($display->frm_form_id)) { $display = FrmProDisplaysHelper::setup_edit_vars($display, false); } if (!isset($display->frm_form_id) or empty($display->frm_form_id)) { return $content; } // check if entry needs to be deleted before loading entries if (FrmAppHelper::get_param('frm_action') == 'destroy' && isset($_GET['entry'])) { $deleted = FrmProEntriesController::ajax_destroy($display->frm_form_id, false, false); if (!empty($deleted)) { $message = '<div class="with_frm_style"><div class="frm_message">' . $deleted . '</div></div>'; } unset($_GET['entry']); } //for backwards compatability $display->id = $display->frm_old_id; $display->display_key = $display->post_name; $defaults = array('filter' => false, 'user_id' => '', 'limit' => '', 'page_size' => '', 'order_by' => '', 'order' => '', 'drafts' => false, 'auto_id' => ''); extract(wp_parse_args($extra_atts, $defaults)); //if (FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // self::parse_pretty_entry_url(); if ($display->frm_show_count == 'one' and is_numeric($display->frm_entry_id) and $display->frm_entry_id > 0 and !$entry_id) { $entry_id = $display->frm_entry_id; } $entry = false; $show = 'all'; global $wpdb, $frmpro_entry; $where = $wpdb->prepare('it.form_id=%d', $display->frm_form_id); if (in_array($display->frm_show_count, array('dynamic', 'calendar', 'one'))) { $one_param = isset($_GET['entry']) ? $_GET['entry'] : $auto_id; $get_param = isset($_GET[$display->frm_param]) ? $_GET[$display->frm_param] : ($display->frm_show_count == 'one' ? $one_param : $auto_id); unset($one_param); if ($get_param) { if (($display->frm_type == 'id' or $display->frm_show_count == 'one') and is_numeric($get_param)) { $where .= $wpdb->prepare(' AND it.id=%d', $get_param); } else { $where .= $wpdb->prepare(' AND it.item_key=%s', $get_param); } $entry = $frm_entry->getAll($where, '', 1, 0); if ($entry) { $entry = reset($entry); } if ($entry and $entry->post_id) { //redirect to single post page if this entry is a post if (in_the_loop() and $display->frm_show_count != 'one' and !is_single($entry->post_id) and $post->ID != $entry->post_id) { $this_post = get_post($entry->post_id); if (in_array($this_post->post_status, array('publish', 'private'))) { die(FrmAppHelper::js_redirect(get_permalink($entry->post_id))); } } } } unset($get_param); } if ($entry and in_array($display->frm_show_count, array('dynamic', 'calendar'))) { $new_content = $display->frm_dyncontent; $show = 'one'; } else { $new_content = $display->post_content; } $show = $display->frm_show_count == 'one' ? 'one' : $show; $shortcodes = FrmProDisplaysHelper::get_shortcodes($new_content, $display->frm_form_id); //don't let page size and limit override single entry displays if ($display->frm_show_count == 'one') { $display->frm_page_size = $display->frm_limit = ''; } //don't keep current content if post type is frm_display if ($post and $post->post_type == 'frm_display') { $display->frm_insert_loc = ''; } $pagination = ''; $is_draft = !empty($drafts) ? 1 : 0; $form_query = $wpdb->prepare("SELECT id, post_id FROM {$wpdb->prefix}frm_items WHERE form_id=%d and post_id>%d", $display->frm_form_id, 1); if ($drafts != 'both') { $form_query .= $wpdb->prepare(' AND is_draft=%d', $is_draft); } if ($entry and $entry->form_id == $display->frm_form_id) { $form_query .= $wpdb->prepare(' AND id=%d', $entry->id); $form_posts = $wpdb->get_results($form_query); $entry_ids = array($entry->id); } else { $form_posts = $wpdb->get_results($form_query); //Only get $entry_ids if filters are set or if frm_search parameter is set if (isset($display->frm_where) && !empty($display->frm_where) && (!$entry || !$post || empty($auto_id)) || isset($_GET['frm_search'])) { $entry_query = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $display->frm_form_id); if ($drafts != 'both') { $entry_query .= $wpdb->prepare(" AND is_draft=%d", $is_draft); } $entry_ids = $wpdb->get_col($entry_query); unset($entry_query); } } unset($form_query); $empty_msg = (isset($display->frm_empty_msg) and !empty($display->frm_empty_msg)) ? '<div class="frm_no_entries">' . FrmProFieldsHelper::get_default_value($display->frm_empty_msg, false, true, true) . '</div>' : ''; if (isset($message)) { // if an entry was deleted above, show a message $empty_msg = $message . $empty_msg; } $after_where = false; if ($user_id and !empty($user_id)) { $user_id = FrmProAppHelper::get_user_id_param($user_id); $uid_used = false; } if (isset($display->frm_where) && !empty($display->frm_where) && (!$entry || !$post || empty($auto_id))) { $display->frm_where = apply_filters('frm_custom_where_opt', $display->frm_where, array('display' => $display, 'entry' => $entry)); $continue = false; foreach ($display->frm_where as $where_key => $where_opt) { $where_val = isset($display->frm_where_val[$where_key]) ? $display->frm_where_val[$where_key] : ''; if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); //if this param doesn't exist, then don't include it if ($where_val == '') { if (!$after_where) { $continue = true; } continue; } } else { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); } $continue = false; if ($where_val == 'current_user') { if ($user_id and is_numeric($user_id)) { $where_val = $user_id; $uid_used = true; } else { $where_val = get_current_user_id(); } } $where_val = do_shortcode($where_val); if (in_array($where_opt, array('id', 'item_key', 'post_id')) && !is_array($where_val) && strpos($where_val, ',')) { $where_val = explode(',', $where_val); } if (is_array($where_val) and !empty($where_val)) { $new_where = '('; if (strpos($display->frm_where_is[$where_key], 'LIKE') !== false) { foreach ($where_val as $w) { if ($new_where != '(') { $new_where .= ','; } $new_where .= $wpdb->prepare('%s', '%' . FrmAppHelper::esc_like($w) . '%'); unset($w); } } else { foreach ($where_val as $w) { if ($new_where != '(') { $new_where .= ','; } $new_where .= $wpdb->prepare('%s', $w); unset($w); } } $new_where .= ')'; $where_val = $new_where; unset($new_where); if (strpos($display->frm_where_is[$where_key], '!') === false && strpos($display->frm_where_is[$where_key], 'not') === false) { $display->frm_where_is[$where_key] = ' in '; } else { $display->frm_where_is[$where_key] = ' not in '; } } if (is_numeric($where_opt)) { $filter_opts = apply_filters('frm_display_filter_opt', array('where_opt' => $where_opt, 'where_is' => $display->frm_where_is[$where_key], 'where_val' => $where_val, 'form_id' => $display->frm_form_id, 'form_posts' => $form_posts, 'after_where' => $after_where, 'display' => $display, 'drafts' => $is_draft)); $entry_ids = FrmProAppHelper::filter_where($entry_ids, $filter_opts); unset($filter_opts); $after_where = true; $continue = false; if (empty($entry_ids)) { break; } } else { if ($where_opt == 'created_at' or $where_opt == 'updated_at') { if ($where_val == 'NOW') { $where_val = current_time('mysql', 1); } if (strpos($display->frm_where_is[$where_key], 'LIKE') === false) { $where_val = date('Y-m-d H:i:s', strtotime($where_val)); } $where .= $wpdb->prepare(" and it.{$where_opt} " . $display->frm_where_is[$where_key] . "%s", ''); if (strpos($display->frm_where_is[$where_key], 'in')) { $where .= " {$where_val}"; } else { if (strpos($display->frm_where_is[$where_key], 'LIKE') !== false) { $where .= $wpdb->prepare(" %s", '%' . FrmAppHelper::esc_like($where_val) . '%'); } else { $where .= $wpdb->prepare(" %s", $where_val); } } $continue = true; } else { if (in_array($where_opt, array('id', 'item_key', 'post_id'))) { $where .= " and it.{$where_opt} " . $display->frm_where_is[$where_key]; if (strpos($display->frm_where_is[$where_key], 'in')) { $where .= " {$where_val}"; } else { $where .= $wpdb->prepare(" %s", $where_val); } $continue = true; } } } } if (!$continue and empty($entry_ids)) { if ($display->frm_insert_loc == 'after') { $content .= $empty_msg; } else { if ($display->frm_insert_loc == 'before') { $content = $empty_msg . $content; } else { if ($filter) { $empty_msg = apply_filters('the_content', $empty_msg); } if ($post->post_type == 'frm_display' and in_the_loop()) { $content = ''; } $content .= $empty_msg; } } return $content; } } if ($user_id && is_numeric($user_id) && !$uid_used) { $where .= $wpdb->prepare(" AND it.user_id=%d", $user_id); } $s = FrmAppHelper::get_param('frm_search', false); if ($s) { $new_ids = FrmProEntriesHelper::get_search_ids($s, $display->frm_form_id); if ($after_where and isset($entry_ids) and !empty($entry_ids)) { $entry_ids = array_intersect($new_ids, $entry_ids); } else { $entry_ids = $new_ids; } if (empty($entry_ids)) { if ($post->post_type == 'frm_display' and in_the_loop()) { $content = ''; } return $content . ' ' . $empty_msg; } } if (isset($entry_ids) && !empty($entry_ids)) { $where .= ' and it.id in (' . implode(',', array_filter($entry_ids, 'is_numeric')) . ')'; } if ($entry_id) { $entry_id_array = explode(',', $entry_id); //Get IDs (if there are any) $numeric_entry_ids = array_filter($entry_id_array, 'is_numeric'); //If there are entry keys, use esc_sql if (empty($numeric_entry_ids)) { $entry_id_array = array_filter($entry_id_array, 'esc_sql'); } $where .= !empty($numeric_entry_ids) ? " and it.id in ('" . implode("','", $numeric_entry_ids) . "')" : " and it.item_key in ('" . implode("','", $entry_id_array) . "')"; } if ($drafts != 'both') { $where .= $wpdb->prepare(' AND is_draft=%d', $is_draft); } unset($is_draft); if ($show == 'one') { $limit = ' LIMIT 1'; } else { if (isset($_GET['frm_cat']) and isset($_GET['frm_cat_id'])) { //Get fields with specified field value 'frm_cat' = field key/id, 'frm_cat_id' = order position of selected option global $frm_field; if ($cat_field = $frm_field->getOne($_GET['frm_cat'])) { $categories = maybe_unserialize($cat_field->options); if (isset($categories[$_GET['frm_cat_id']])) { $cat_entry_ids = $frm_entry_meta->getEntryIds(array('meta_value' => $categories[$_GET['frm_cat_id']], 'fi.field_key' => $_GET['frm_cat'])); if ($cat_entry_ids) { $where .= " and it.id in (" . implode(',', $cat_entry_ids) . ")"; } else { $where .= " and it.id=0"; } } } } } if (!empty($limit) and is_numeric($limit)) { $display->frm_limit = (int) $limit; } if (is_numeric($display->frm_limit)) { $num_limit = (int) $display->frm_limit; $limit = ' LIMIT ' . $display->frm_limit; } if (!empty($order_by)) { $display->frm_order_by = explode(',', $order_by); $order_by = ''; } if (!empty($order)) { $display->frm_order = explode(',', $order); } unset($order); if (!empty($page_size) && is_numeric($page_size)) { $display->frm_page_size = (int) $page_size; } // if limit is lower than page size, ignore the page size if (isset($num_limit) && $display->frm_page_size > $num_limit) { $display->frm_page_size = ''; } if (isset($display->frm_page_size) and is_numeric($display->frm_page_size)) { $page_param = ($_GET and isset($_GET['frm-page-' . $display->ID])) ? 'frm-page-' . $display->ID : 'frm-page'; $current_page = (int) FrmAppHelper::get_param($page_param, 1); $record_where = $where == $wpdb->prepare('it.form_id=%d', $display->frm_form_id) ? $display->frm_form_id : $where; $record_count = $frm_entry->getRecordCount($record_where); if (isset($num_limit) and $record_count > (int) $num_limit) { $record_count = (int) $num_limit; } $page_count = $frm_entry->getPageCount($display->frm_page_size, $record_count); //Get a page of entries $entries = $frmpro_entry->get_view_page($current_page, $display->frm_page_size, $where, array('order_by_array' => $display->frm_order_by, 'order_array' => $display->frm_order, 'posts' => $form_posts)); $page_last_record = FrmAppHelper::getLastRecordNum($record_count, $current_page, $display->frm_page_size); $page_first_record = FrmAppHelper::getFirstRecordNum($record_count, $current_page, $display->frm_page_size); if ($page_count > 1) { $page_param = 'frm-page-' . $display->ID; $pagination = FrmProDisplaysController::get_pagination_file(FrmAppHelper::plugin_path() . '/pro/classes/views/displays/pagination.php', compact('current_page', 'record_count', 'page_count', 'page_last_record', 'page_first_record', 'page_param')); } } else { //Get all entries $entries = $frmpro_entry->get_view_results($where, array('order_by_array' => $display->frm_order_by, 'order_array' => $display->frm_order, 'limit' => $limit, 'posts' => $form_posts)); } $total_count = count($entries); $sc_atts = array(); if (isset($record_count)) { $sc_atts['record_count'] = $record_count; } else { $sc_atts['record_count'] = $total_count; } $display_content = ''; if (isset($message)) { // if an entry was deleted above, show a message $display_content .= $message; } if ($show == 'all') { $display_content .= isset($display->frm_before_content) ? $display->frm_before_content : ''; } if (!isset($entry_ids) || empty($entry_ids)) { $entry_ids = array_keys($entries); } $display_content = apply_filters('frm_before_display_content', $display_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); $filtered_content = apply_filters('frm_display_entries_content', $new_content, $entries, $shortcodes, $display, $show, $sc_atts); if ($filtered_content != $new_content) { $display_content .= $filtered_content; } else { $odd = 'odd'; $count = 0; if (!empty($entries)) { foreach ($entries as $entry) { $count++; //TODO: use the count with conditionals $display_content .= apply_filters('frm_display_entry_content', $new_content, $entry, $shortcodes, $display, $show, $odd, array('count' => $count, 'total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'pagination' => $pagination, 'entry_ids' => $entry_ids)); $odd = $odd == 'odd' ? 'even' : 'odd'; unset($entry); } unset($count); } else { if ($post->post_type == 'frm_display' and in_the_loop()) { $display_content = ''; } if (!isset($message) || FrmAppHelper::get_param('frm_action') != 'destroy') { $display_content .= $empty_msg; } } } if (isset($message)) { unset($message); } if ($show == 'all') { $display_content .= isset($display->frm_after_content) ? apply_filters('frm_after_content', $display->frm_after_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)) : ''; } if (!isset($sc_atts)) { $sc_atts = array('record_count' => 0); } if (!isset($total_count)) { $total_count = 0; } $display_content .= apply_filters('frm_after_display_content', $pagination, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); unset($sc_atts); $display_content = FrmProFieldsHelper::get_default_value($display_content, false, true, true); if ($display->frm_insert_loc == 'after') { $content .= $display_content; } else { if ($display->frm_insert_loc == 'before') { $content = $display_content . $content; } else { if ($filter) { $display_content = apply_filters('the_content', $display_content); } $content = $display_content; } } return $content; }
</a> <a href="?page=formidable-entries&frm_action=duplicate&form=<?php echo $form->id; ?> &id=<?php echo $record->id; ?> " class="button-secondary alignright" style="margin-right:10px"><?php _e('Duplicate', 'formidable'); ?> </a> <div class="clear"></div> <p class="howto"> <?php FrmProEntriesHelper::resend_email_links($record->id, $form->id); ?> </p> </div> </div> <div id="major-publishing-actions"> <div id="delete-action"> <a class="submitdelete deletion" href="?page=formidable-entries&frm_action=destroy&id=<?php echo $record->id; ?> &form=<?php echo $form->id; ?> " onclick="return confirm('<?php
/** * @since 2.0.8 * @return boolean */ public static function user_can_submit_form($form) { $admin_entry = FrmAppHelper::is_admin(); $can_submit = true; if ($form->options['single_entry_type'] == 'cookie' && isset($_COOKIE['frm_form' . $form->id . '_' . COOKIEHASH])) { $can_submit = $admin_entry ? true : false; } else { if ($form->options['single_entry_type'] == 'ip') { if (!$admin_entry) { $prev_entry = FrmEntry::getAll(array('it.form_id' => $form->id, 'it.ip' => FrmAppHelper::get_ip_address()), '', 1); if ($prev_entry) { $can_submit = false; } } } else { if (($form->options['single_entry_type'] == 'user' || isset($form->options['save_draft']) && $form->options['save_draft'] == 1) && !$form->editable) { $user_ID = get_current_user_id(); if ($user_ID) { $meta = FrmProEntriesHelper::check_for_user_entry($user_ID, $form, $form->options['single_entry_type'] != 'user'); if ($meta) { $can_submit = false; } } } } } return $can_submit; }
<div class="misc-pub-section"> <span class="misc-pub-revisions frm_icon_font frm_email_icon"> <?php printf(__('Emails: %1$s', 'formidable'), FrmProEntriesHelper::resend_email_links($entry->id, $entry->form_id, array('label' => __('Resend', 'formidable'), 'echo' => false))); ?> </span> </div>
public static function get_display_data($display, $content = '', $entry_id = false, $extra_atts = array()) { if (post_password_required($display)) { return get_the_password_form($display); } add_action('frm_load_view_hooks', 'FrmProDisplaysController::trigger_load_view_hooks'); FrmAppHelper::trigger_hook_load('view', $display); global $frm_vars, $post; $frm_vars['forms_loaded'][] = true; if (!isset($display->frm_empty_msg)) { $display = FrmProDisplaysHelper::setup_edit_vars($display, false); } if (!isset($display->frm_form_id) || empty($display->frm_form_id)) { return $content; } //for backwards compatability $display->id = $display->frm_old_id; $display->display_key = $display->post_name; $defaults = array('filter' => false, 'user_id' => '', 'limit' => '', 'page_size' => '', 'order_by' => '', 'order' => '', 'drafts' => false, 'auto_id' => ''); $extra_atts = wp_parse_args($extra_atts, $defaults); extract($extra_atts); //if (FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // self::parse_pretty_entry_url(); if ($display->frm_show_count == 'one' && is_numeric($display->frm_entry_id) && $display->frm_entry_id > 0 && !$entry_id) { $entry_id = $display->frm_entry_id; } $entry = false; $show = 'all'; // Don't filter with $entry_ids by default because the query gets too long. // Only filter with $entry_ids when showing one entry $use_ids = false; global $wpdb; $where = array('it.form_id' => $display->frm_form_id); if (in_array($display->frm_show_count, array('dynamic', 'calendar', 'one'))) { $one_param = FrmAppHelper::simple_get('entry', 'sanitize_title', $extra_atts['auto_id']); $get_param = FrmAppHelper::simple_get($display->frm_param, 'sanitize_title', $display->frm_show_count == 'one' ? $one_param : $extra_atts['auto_id']); unset($one_param); if ($get_param) { if (($display->frm_type == 'id' || $display->frm_show_count == 'one') && is_numeric($get_param)) { $where['it.id'] = $get_param; } else { $where['it.item_key'] = $get_param; } $entry = FrmEntry::getAll($where, '', 1, 0); if ($entry) { $entry = reset($entry); } if ($entry && $entry->post_id) { //redirect to single post page if this entry is a post if (in_the_loop() && $display->frm_show_count != 'one' && !is_single($entry->post_id) && $post->ID != $entry->post_id) { $this_post = get_post($entry->post_id); if (in_array($this_post->post_status, array('publish', 'private'))) { die(FrmAppHelper::js_redirect(get_permalink($entry->post_id))); } } } } unset($get_param); } if ($entry && in_array($display->frm_show_count, array('dynamic', 'calendar'))) { $new_content = $display->frm_dyncontent; $show = 'one'; } else { $new_content = $display->post_content; } $show = $display->frm_show_count == 'one' ? 'one' : $show; $shortcodes = FrmProDisplaysHelper::get_shortcodes($new_content, $display->frm_form_id); //don't let page size and limit override single entry displays if ($display->frm_show_count == 'one') { $display->frm_page_size = $display->frm_limit = ''; } //don't keep current content if post type is frm_display if ($post && $post->post_type == self::$post_type) { $display->frm_insert_loc = ''; } $pagination = ''; $form_query = array('form_id' => $display->frm_form_id, 'post_id >' => 1); if ($extra_atts['drafts'] != 'both') { $is_draft = empty($extra_atts['drafts']) ? 0 : 1; $form_query['is_draft'] = $is_draft; } else { $is_draft = 'both'; } if ($entry && $entry->form_id == $display->frm_form_id) { $form_query['id'] = $entry->id; } $form_posts = FrmDb::get_results('frm_items', $form_query, 'id, post_id'); unset($form_query); $getting_entries = !$entry || !$post || empty($extra_atts['auto_id']); $check_filter_opts = !empty($display->frm_where) && $getting_entries; if ($entry && $entry->form_id == $display->frm_form_id) { $entry_ids = array($entry->id); // Filter by this entry ID to make query faster $use_ids = true; } else { if ($check_filter_opts || isset($_GET['frm_search'])) { //Only get $entry_ids if filters are set or if frm_search parameter is set $entry_query = array('form_id' => $display->frm_form_id); if ($extra_atts['drafts'] != 'both') { $entry_query['is_draft'] = $is_draft; } $entry_ids = FrmDb::get_col('frm_items', $entry_query); unset($entry_query); } } $empty_msg = isset($display->frm_empty_msg) && !empty($display->frm_empty_msg) ? '<div class="frm_no_entries">' . FrmProFieldsHelper::get_default_value($display->frm_empty_msg, false) . '</div>' : ''; if (isset($message)) { // if an entry was deleted above, show a message $empty_msg = $message . $empty_msg; } $after_where = false; $user_id = $extra_atts['user_id']; if (!empty($user_id)) { $user_id = FrmAppHelper::get_user_id_param($user_id); $uid_used = false; } self::add_group_by_filter($display, $getting_entries); unset($getting_entries); if ($check_filter_opts) { $display->frm_where = apply_filters('frm_custom_where_opt', $display->frm_where, array('display' => $display, 'entry' => $entry)); $continue = false; foreach ($display->frm_where as $where_key => $where_opt) { $where_val = isset($display->frm_where_val[$where_key]) ? $display->frm_where_val[$where_key] : ''; if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); //if this param doesn't exist, then don't include it if ($where_val == '') { if (!$after_where) { $continue = true; } continue; } } else { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); } $continue = false; if ($where_val == 'current_user') { if ($user_id && is_numeric($user_id)) { $where_val = $user_id; $uid_used = true; } else { $where_val = get_current_user_id(); } } else { if (!is_array($where_val)) { $where_val = do_shortcode($where_val); } } if (in_array($where_opt, array('id', 'item_key', 'post_id')) && !is_array($where_val) && strpos($where_val, ',')) { $where_val = explode(',', $where_val); $where_val = array_filter($where_val); } if (is_array($where_val) && !empty($where_val)) { if (strpos($display->frm_where_is[$where_key], '!') === false && strpos($display->frm_where_is[$where_key], 'not') === false) { $display->frm_where_is[$where_key] = ' in '; } else { $display->frm_where_is[$where_key] = 'not in'; } } if (is_numeric($where_opt)) { $filter_opts = apply_filters('frm_display_filter_opt', array('where_opt' => $where_opt, 'where_is' => $display->frm_where_is[$where_key], 'where_val' => $where_val, 'form_id' => $display->frm_form_id, 'form_posts' => $form_posts, 'after_where' => $after_where, 'display' => $display, 'drafts' => $is_draft, 'use_ids' => $use_ids)); $entry_ids = FrmProAppHelper::filter_where($entry_ids, $filter_opts); unset($filter_opts); $after_where = true; $continue = false; if (empty($entry_ids)) { break; } } else { if (in_array($where_opt, array('created_at', 'updated_at'))) { if ($where_val == 'NOW') { $where_val = current_time('mysql', 1); } if (strpos($display->frm_where_is[$where_key], 'LIKE') === false) { $where_val = date('Y-m-d H:i:s', strtotime($where_val)); // If using less than or equal to, set the time to the end of the day if ($display->frm_where_is[$where_key] == '<=') { $where_val = str_replace('00:00:00', '23:59:59', $where_val); } // Convert date to GMT since that is the format in the DB $where_val = get_gmt_from_date($where_val); } $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val; $continue = true; } else { if (in_array($where_opt, array('id', 'item_key', 'post_id', 'ip'))) { $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val; // Update entry IDs if the entry ID filter is set to "equal to" if ($where_opt == 'id' && in_array($display->frm_where_is[$where_key], array('=', ' in '))) { $entry_ids = $where_val; } $continue = true; } } } } if (!$continue && empty($entry_ids)) { if ($display->frm_insert_loc == 'after') { $content .= $empty_msg; } else { if ($display->frm_insert_loc == 'before') { $content = $empty_msg . $content; } else { if ($filter) { $empty_msg = apply_filters('the_content', $empty_msg); } if ($post && $post->post_type == self::$post_type && in_the_loop()) { $content = ''; } $content .= $empty_msg; } } return $content; } } if ($user_id && is_numeric($user_id) && !$uid_used) { $where['it.user_id'] = $user_id; } $s = FrmAppHelper::get_param('frm_search', false, 'get', 'sanitize_text_field'); if ($s) { $new_ids = FrmProEntriesHelper::get_search_ids($s, $display->frm_form_id, array('is_draft' => $extra_atts['drafts'])); if ($after_where && isset($entry_ids) && !empty($entry_ids)) { $entry_ids = array_intersect($new_ids, $entry_ids); } else { $entry_ids = $new_ids; } if (empty($entry_ids)) { if ($post->post_type == self::$post_type && in_the_loop()) { $content = ''; } return $content . ' ' . $empty_msg; } } if (isset($entry_ids) && !empty($entry_ids)) { $where['it.id'] = $entry_ids; } self::maybe_add_entry_query($entry_id, $where); if ($extra_atts['drafts'] != 'both') { $where['is_draft'] = $is_draft; } unset($is_draft); if ($show == 'one') { $limit = ' LIMIT 1'; } else { self::maybe_add_cat_query($where); } if (!empty($limit) && is_numeric($limit)) { $display->frm_limit = (int) $limit; } if (is_numeric($display->frm_limit)) { $num_limit = (int) $display->frm_limit; $limit = ' LIMIT ' . $display->frm_limit; } if (!empty($order_by)) { $display->frm_order_by = explode(',', $order_by); } if (!empty($order)) { $display->frm_order = explode(',', $order); if (!isset($display->frm_order_by[0])) { $display->frm_order_by = FrmProAppHelper::reset_keys($display->frm_order_by); } } unset($order); if (!empty($page_size) && is_numeric($page_size)) { $display->frm_page_size = (int) $page_size; } // if limit is lower than page size, ignore the page size if (isset($num_limit) && $display->frm_page_size > $num_limit) { $display->frm_page_size = ''; } $display_page_query = array('order_by_array' => $display->frm_order_by, 'order_array' => $display->frm_order, 'posts' => $form_posts, 'display' => $display); if (isset($display->frm_page_size) && is_numeric($display->frm_page_size)) { $page_param = $_GET && isset($_GET['frm-page-' . $display->ID]) ? 'frm-page-' . $display->ID : 'frm-page'; $current_page = FrmAppHelper::simple_get($page_param, 'absint', 1); $record_count = FrmEntry::getRecordCount($where); if (isset($num_limit) && $record_count > (int) $num_limit) { $record_count = (int) $num_limit; } $page_count = FrmEntry::getPageCount($display->frm_page_size, $record_count); $entry_ids = FrmProEntry::get_view_page($current_page, $display->frm_page_size, $where, $display_page_query); $page_last_record = FrmAppHelper::get_last_record_num($record_count, $current_page, $display->frm_page_size); $page_first_record = FrmAppHelper::get_first_record_num($record_count, $current_page, $display->frm_page_size); if ($page_count > 1) { $page_param = 'frm-page-' . $display->ID; $pagination = FrmAppHelper::get_file_contents(FrmAppHelper::plugin_path() . '/pro/classes/views/displays/pagination.php', compact('current_page', 'record_count', 'page_count', 'page_last_record', 'page_first_record', 'page_param')); } } else { $display_page_query['limit'] = $limit; //Get all entries $entry_ids = FrmProEntry::get_view_results($where, $display_page_query); } $total_count = count($entry_ids); $sc_atts = array(); if (isset($record_count)) { $sc_atts['record_count'] = $record_count; } else { $sc_atts['record_count'] = $total_count; } $display_content = ''; if (isset($message)) { // if an entry was deleted above, show a message $display_content .= $message; } if ($show == 'all') { $display_content .= isset($display->frm_before_content) ? $display->frm_before_content : ''; } add_filter('frm_before_display_content', 'FrmProDisplaysController::calendar_header', 10, 3); add_filter('frm_before_display_content', 'FrmProDisplaysController::filter_after_content', 10, 4); $display_content = apply_filters('frm_before_display_content', $display_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); add_filter('frm_display_entries_content', 'FrmProDisplaysController::build_calendar', 10, 5); $filtered_content = apply_filters('frm_display_entries_content', $new_content, $entry_ids, $shortcodes, $display, $show, $sc_atts); if ($filtered_content != $new_content) { $display_content .= $filtered_content; } else { $odd = 'odd'; $count = 0; if (!empty($entry_ids)) { $loop_entry_ids = $entry_ids; while ($next_set = array_splice($loop_entry_ids, 0, 30)) { $entries = FrmEntry::getAll(array('id' => $next_set), ' ORDER BY FIELD(it.id,' . implode(',', $next_set) . ')', '', true, false); foreach ($entries as $entry) { $count++; //TODO: use the count with conditionals $display_content .= apply_filters('frm_display_entry_content', $new_content, $entry, $shortcodes, $display, $show, $odd, array('count' => $count, 'total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'pagination' => $pagination, 'entry_ids' => $entry_ids)); $odd = $odd == 'odd' ? 'even' : 'odd'; unset($entry); } unset($entries); } unset($loop_entry_ids, $count); } else { if ($post && $post->post_type == self::$post_type && in_the_loop()) { $display_content = ''; } if (!isset($message) || FrmAppHelper::get_param('frm_action', '', 'get', 'sanitize_title') != 'destroy') { $display_content .= $empty_msg; } } } if (isset($message)) { unset($message); } if ($show == 'all' && isset($display->frm_after_content)) { add_filter('frm_after_content', 'FrmProDisplaysController::filter_after_content', 10, 4); $display_content .= apply_filters('frm_after_content', $display->frm_after_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); } if (!isset($sc_atts)) { $sc_atts = array('record_count' => 0); } if (!isset($total_count)) { $total_count = 0; } $pagination = self::calendar_footer($pagination, $display, $show); $display_content .= apply_filters('frm_after_display_content', $pagination, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); unset($sc_atts); $display_content = FrmProFieldsHelper::get_default_value($display_content, false, true, false); if ($display->frm_insert_loc == 'after') { $content .= $display_content; } else { if ($display->frm_insert_loc == 'before') { $content = $display_content . $content; } else { if ($filter) { $display_content = apply_filters('the_content', $display_content); } $content = $display_content; } } // load the styling for css classes and pagination FrmStylesController::enqueue_style(); return $content; }
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; }
public static function setup_edit_vars($values, $record = false) { return FrmProEntriesHelper::setup_edit_vars($values, $record); }
function get_display_data($display, $content = '', $entry_id = false, $extra_atts = array()) { global $frmpro_display, $frm_entry, $frmpro_settings, $frm_entry_meta, $frm_forms_loaded; $frm_forms_loaded[] = true; $defaults = array('filter' => false, 'user_id' => '', 'limit' => '', 'page_size' => '', 'order_by' => '', 'order' => ''); extract(wp_parse_args($extra_atts, $defaults)); if (FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks) { $this->parse_pretty_entry_url(); } if (is_numeric($display->entry_id) && $display->entry_id > 0 and !$entry_id) { $entry_id = $display->entry_id; } $entry = false; $show = 'all'; if (in_array($display->show_count, array('dynamic', 'calendar', 'one'))) { $one_param = isset($_GET['entry']) ? $_GET['entry'] : $entry_id; $get_param = isset($_GET[$display->param]) ? $_GET[$display->param] : ($display->show_count == 'one' ? $one_param : $entry_id); unset($one_param); if ($get_param) { $where_entry = array('it.form_id' => $display->form_id); if (($display->type == 'id' or $display->show_count == 'one') and is_numeric($get_param)) { $where_entry['it.id'] = $get_param; } else { $where_entry['it.item_key'] = $get_param; } $entry = $frm_entry->getAll($where_entry, '', 1, 0); if ($entry) { $entry = reset($entry); } if ($entry and $entry->post_id) { //redirect to single post page if this entry is a post global $post; if (in_the_loop() and $display->show_count != 'one' and !is_single($entry->post_id) and $post->ID != $entry->post_id) { $this_post = get_post($entry->post_id); if (in_array($this_post->post_status, array('publish', 'private'))) { die('<script type="text/javascript">window.location="' . get_permalink($entry->post_id) . '"</script>'); } } } } unset($get_param); } if ($entry and in_array($display->show_count, array('dynamic', 'calendar'))) { $new_content = stripslashes($display->dyncontent); $show = 'one'; } else { $new_content = stripslashes($display->content); } $show = ($display->show_count == 'one' or $entry_id and is_numeric($entry_id)) ? 'one' : $show; $shortcodes = FrmProDisplaysHelper::get_shortcodes($new_content, $display->form_id); $pagination = ''; if ($entry and $entry->form_id == $display->form_id) { $display_content = FrmProFieldsHelper::replace_shortcodes($new_content, $entry, $shortcodes, $display, $show); } else { global $frmdb, $wpdb; $options = maybe_unserialize($display->options); $empty_msg = '<div class="frm_no_entries">' . (isset($options['empty_msg']) ? stripslashes($options['empty_msg']) : '') . '</div>'; $display_content = ''; if ($show == 'all') { $display_content .= isset($options['before_content']) ? stripslashes($options['before_content']) : ''; } $display_content = apply_filters('frm_before_display_content', $display_content, $display, $show); $where = 'it.form_id=' . $display->form_id; $form_posts = $frmdb->get_records($frmdb->entries, array('form_id' => $display->form_id, 'post_id >' => 1), '', '', 'id,post_id'); $entry_ids = $frmdb->get_col($frmdb->entries, array('form_id' => $display->form_id), 'id'); $after_where = false; if ($user_id and !empty($user_id)) { $user_id = FrmProAppHelper::get_user_id_param($user_id); $uid_used = false; } if (isset($options['where']) and !empty($options['where'])) { $options['where'] = apply_filters('frm_custom_where_opt', $options['where'], array('display' => $display, 'entry' => $entry)); $continue = false; foreach ($options['where'] as $where_key => $where_opt) { $where_val = isset($options['where_val'][$where_key]) ? $options['where_val'][$where_key] : ''; if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); //if this param doesn't exist, then don't include it if ($where_val == '') { if (!$after_where) { $continue = true; } continue; } } else { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); } $continue = false; if ($where_val == 'current_user') { if ($user_id and is_numeric($user_id)) { $where_val = $user_id; $uid_used = true; } else { global $user_ID; $where_val = $user_ID; } } $where_val = do_shortcode($where_val); if (is_array($where_val) and !empty($where_val)) { $new_where = '('; if (strpos($options['where_is'][$where_key], 'LIKE') !== false) { foreach ($where_val as $w) { if ($new_where != '(') { $new_where .= ','; } $new_where .= "'%" . esc_sql(like_escape($w)) . "%'"; unset($w); } } else { foreach ($where_val as $w) { if ($new_where != '(') { $new_where .= ','; } $new_where .= "'" . esc_sql($w) . "'"; unset($w); } } $new_where .= ')'; $where_val = $new_where; unset($new_where); if (strpos($options['where_is'][$where_key], '!') === false and strpos($options['where_is'][$where_key], 'not') === false) { $options['where_is'][$where_key] = ' in '; } else { $options['where_is'][$where_key] = ' not in '; } } if (is_numeric($where_opt)) { $entry_ids = FrmProAppHelper::filter_where($entry_ids, array('where_opt' => $where_opt, 'where_is' => $options['where_is'][$where_key], 'where_val' => $where_val, 'form_id' => $display->form_id, 'form_posts' => $form_posts, 'after_where' => $after_where)); $after_where = true; $continue = false; if (empty($entry_ids)) { break; } } else { if ($where_opt == 'created_at') { if ($where_val == 'NOW') { $where_val = current_time('mysql', 1); } $where_val = date('Y-m-d H:i:s', strtotime($where_val)); $where .= " and it.created_at " . $options['where_is'][$where_key]; if (strpos($options['where_is'][$where_key], 'in')) { $where .= " {$where_val}"; } else { $where .= " '" . esc_sql($where_val) . "'"; } $continue = true; } else { if ($where_opt == 'id' or $where_opt == 'item_key') { $where .= " and it.{$where_opt} " . $options['where_is'][$where_key]; if (strpos($options['where_is'][$where_key], 'in')) { $where .= " {$where_val}"; } else { $where .= " '" . esc_sql($where_val) . "'"; } $continue = true; } } } } if (!$continue and empty($entry_ids)) { return $content . ' ' . $empty_msg; } } if ($user_id and is_numeric($user_id) and !$uid_used) { $where .= " AND it.user_id=" . (int) $user_id; } $s = FrmAppHelper::get_param('frm_search', false); if ($s) { $new_ids = FrmProEntriesHelper::get_search_ids($s, $display->form_id); if ($after_where and isset($entry_ids) and !empty($entry_ids)) { $entry_ids = array_intersect($new_ids, $entry_ids); } else { $entry_ids = $new_ids; } if (empty($entry_ids)) { return $content . ' ' . $empty_msg; } } if (isset($entry_ids) and !empty($entry_ids)) { $where .= ' and it.id in (' . implode(',', $entry_ids) . ')'; } if ($entry_id) { $where .= " and it.id in ({$entry_id})"; } if ($show == 'one') { $limit = ' LIMIT 1'; } else { if (isset($_GET['frm_cat']) and isset($_GET['frm_cat_id'])) { //Get fields with specified field value 'frm_cat' = field key/id, 'frm_cat_id' = order position of selected option global $frm_field; if ($cat_field = $frm_field->getOne($_GET['frm_cat'])) { $categories = maybe_unserialize($cat_field->options); if (isset($categories[$_GET['frm_cat_id']])) { $cat_entry_ids = $frm_entry_meta->getEntryIds("meta_value='" . $categories[$_GET['frm_cat_id']] . "' and fi.field_key='{$_GET['frm_cat']}'"); } if ($cat_entry_ids) { $where .= " and it.id in (" . implode(',', $cat_entry_ids) . ")"; } } } } if (is_array($options)) { if (!empty($limit) and is_numeric($limit)) { $options['limit'] = (int) $limit; } if (is_numeric($options['limit'])) { $num_limit = (int) $options['limit']; $limit = ' LIMIT ' . $options['limit']; } if (!empty($order_by)) { $options['order_by'] = $order_by; } if (!empty($order)) { $options['order'] = $order; } if (isset($options['order_by']) && $options['order_by'] != '') { /*if( $wpdb->has_cap( 'collation' ) ){ $charset_collate = ''; if( !empty($wpdb->charset) ) $charset_collate .= "DEFAULT CHARACTER SET $wpdb->charset"; if( !empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate"; }*/ $order = isset($options['order']) ? ' ' . $options['order'] : ''; if ($options['order_by'] == 'rand') { $order_by = ' RAND()'; } else { if (is_numeric($options['order_by'])) { global $frm_entry_meta, $frm_field; $order_field = $frm_field->getOne($options['order_by']); $order_field->field_options = maybe_unserialize($order_field->field_options); $meta_order = $order_field->type == 'number' ? ' LENGTH(meta_value),' : ''; if (isset($order_field->field_options['post_field']) and $order_field->field_options['post_field']) { $posts = $form_posts; //$frmdb->get_records($frmdb->entries, array('form_id' => $display->form_id, 'post_id >' => 1), '', '', 'id, post_id'); $linked_posts = array(); foreach ($posts as $post_meta) { $linked_posts[$post_meta->post_id] = $post_meta->id; } if ($order_field->field_options['post_field'] == 'post_custom') { $ordered_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='" . $order_field->field_options['custom_field'] . "' AND post_id in (" . implode(',', array_keys($linked_posts)) . ") ORDER BY meta_value" . $order); $metas = array(); foreach ($ordered_ids as $ordered_id) { $metas[] = array('item_id' => $linked_posts[$ordered_id]); } } else { if ($order_field->field_options['post_field'] != 'post_category') { $ordered_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE ID in (" . implode(',', array_keys($linked_posts)) . ") ORDER BY " . $order_field->field_options['post_field'] . ' ' . $order); $metas = array(); foreach ($ordered_ids as $ordered_id) { $metas[] = array('item_id' => $linked_posts[$ordered_id]); } } } } else { if ($order_field->type == 'number') { $query = "SELECT it.*, meta_value +0 as odr FROM {$frmdb->entry_metas} it LEFT OUTER JOIN {$frmdb->fields} fi ON it.field_id=fi.id WHERE fi.form_id={$display->form_id} and fi.id={$options['order_by']}"; if (isset($entry_ids) and !empty($entry_ids)) { $query .= " AND it.item_id in (" . implode(',', $entry_ids) . ")"; } $query .= " ORDER BY odr {$order} {$limit}"; if ($limit == ' LIMIT 1') { $metas = $wpdb->get_row($query); } else { $metas = $wpdb->get_results($query); } } else { $metas = $frm_entry_meta->getAll('fi.form_id=' . $display->form_id . ' and fi.id=' . $options['order_by'], ' ORDER BY ' . $meta_order . ' meta_value' . $order); //TODO: add previous $where and $limit } } if (isset($metas) and is_array($metas) and !empty($metas)) { if ($order_field->type == 'time' and (!isset($order_field->field_options['clock']) or $order_field->field_options['clock'] == 12)) { $new_order = array(); foreach ($metas as $key => $meta) { $parts = str_replace(array(' PM', ' AM'), '', $meta->meta_value); $parts = explode(':', $parts); if (is_array($parts)) { if (preg_match('/PM/', $meta->meta_value) and (int) $parts[0] != 12 or (int) $parts[0] == 12 and preg_match('/AM/', $meta->meta_value)) { $parts[0] = (int) $parts[0] + 12; } } $new_order[$key] = (int) $parts[0] . $parts[1]; unset($key); unset($meta); } //array with sorted times asort($new_order); $final_order = array(); foreach ($new_order as $key => $time) { $final_order[] = $metas[$key]; unset($key); unset($time); } $metas = $final_order; unset($final_order); } $rev_order = ($order == 'DESC' or $order == '') ? ' ASC' : ' DESC'; foreach ($metas as $meta) { $meta = (array) $meta; $order_by .= 'it.id=' . $meta['item_id'] . $rev_order . ', '; } $order_by = rtrim($order_by, ', '); } else { $order_by .= 'it.created_at' . $order; } } else { $order_by = 'it.' . $options['order_by'] . $order; } } $order_by = ' ORDER BY ' . $order_by; } } if (!empty($page_size) and is_numeric($page_size)) { $options['page_size'] = (int) $page_size; } if (isset($options['page_size']) && is_numeric($options['page_size'])) { global $frm_app_helper; $current_page = FrmAppHelper::get_param('frm-page', 1); $record_where = $where == "it.form_id={$display->form_id}" ? $display->form_id : $where; $record_count = $frm_entry->getRecordCount($record_where); if (isset($num_limit) and $record_count > (int) $num_limit) { $record_count = (int) $num_limit; } $page_count = $frm_entry->getPageCount($options['page_size'], $record_count); $entries = $frm_entry->getPage($current_page, $options['page_size'], $where, $order_by); $page_last_record = $frm_app_helper->getLastRecordNum($record_count, $current_page, $options['page_size']); $page_first_record = $frm_app_helper->getFirstRecordNum($record_count, $current_page, $options['page_size']); if ($page_count > 1) { $pagination = FrmProDisplaysController::get_pagination_file(FRMPRO_VIEWS_PATH . '/displays/pagination.php', compact('current_page', 'record_count', 'page_count', 'page_last_record', 'page_first_record')); } } else { $entries = $frm_entry->getAll($where, $order_by, $limit, true, false); } $filtered_content = apply_filters('frm_display_entries_content', $new_content, $entries, $shortcodes, $display, $show); if ($filtered_content != $new_content) { $display_content .= $filtered_content; } else { $odd = 'odd'; $count = 0; if (!empty($entries)) { foreach ($entries as $entry) { $count++; //TODO: use the count with conditionals $display_content .= apply_filters('frm_display_entry_content', $new_content, $entry, $shortcodes, $display, $show, $odd); $odd = $odd == 'odd' ? 'even' : 'odd'; unset($entry); } unset($count); } else { $display_content .= $empty_msg; } } if ($show == 'all') { $display_content .= isset($options['after_content']) ? stripslashes($options['after_content']) : ''; } } $display_content .= apply_filters('frm_after_display_content', $pagination, $display, $show); if ($display->insert_loc == 'after') { $content .= $display_content; } else { if ($display->insert_loc == 'before') { $content = $display_content . $content; } else { if ($filter) { $display_content = apply_filters('the_content', $display_content); } $content = $display_content; } } return $content; }
if (is_array($checked_values)) { if ($col->type == 'data') { $field_value = ''; foreach ($checked_values as $checked_value) { if (!empty($field_value)) { $field_value .= ', '; } $field_value .= FrmProFieldsHelper::get_data_value($checked_value, $col); } } else { $field_value = implode(', ', $checked_values); } } else { $field_value = $checked_values; } $field_value = FrmProEntriesHelper::encode_value($field_value, $charset, $to_encoding); $field_value = str_replace('"', '""', stripslashes($field_value)); //escape for CSV files. } } } } $field_value = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $field_value); echo "\"{$field_value}\","; unset($col); unset($field_value); } $formatted_date = date($wp_date_format, strtotime($entry->created_at)); echo "\"{$formatted_date}\","; echo "\"{$entry->ip}\","; echo "\"{$entry->id}\",";
function extra_tablenav($which) { $footer = $which == 'top' ? false : true; FrmProEntriesHelper::before_table($footer, $this->params['form']); }
public static function allow_form_edit($action, $form) { _deprecated_function(__FUNCTION__, '2.0', 'FrmProEntriesHelper::allow_form_edit'); return FrmProEntriesHelper::allow_form_edit($action, $form); }
<a href="?page=formidable-entries&frm_action=duplicate&form=<?php echo $entry->form_id; ?> &id=<?php echo $id; ?> " class="button-secondary alignright"><?php _e('Duplicate', 'formidable'); ?> </a> <?php } ?> <p class="howto"><?php FrmProEntriesHelper::resend_email_links($entry->id, $entry->form_id); ?> </p> <p class="howto"><a href="#" onclick="window.print();return false;"><?php _e('Print', 'formidable'); ?> </a> <?php do_action('frm_show_entry_publish_box', $entry); ?> </div> </div> <div id="major-publishing-actions"> <?php if (current_user_can('frm_delete_entries')) { ?>
public static function get_export_val($val, $field, $entry = array()) { if ($field->type == 'user_id') { $val = self::get_display_name($val, 'user_login'); } else { if ($field->type == 'file') { $val = self::get_file_name($val, false); } else { if ($field->type == 'date') { $wp_date_format = apply_filters('frm_csv_date_format', 'Y-m-d'); $val = self::get_date($val, $wp_date_format); } else { if ($field->type == 'data') { $new_val = maybe_unserialize($val); if (empty($new_val) && !empty($entry) && FrmProField::is_list_field($field)) { FrmProEntriesHelper::get_dynamic_list_values($field, $entry, $new_val); } if (is_numeric($new_val)) { $val = self::get_data_value($new_val, $field); //replace entry id with specified field } else { if (is_array($new_val)) { $field_value = array(); foreach ($new_val as $v) { $field_value[] = self::get_data_value($v, $field); unset($v); } $val = implode(', ', $field_value); } } } } } } return $val; }
public static function prepare_display_value($entry, $field, $atts) { $field_value = isset($entry->metas[$field->id]) ? $entry->metas[$field->id] : false; if (FrmAppHelper::pro_is_installed()) { FrmProEntriesHelper::get_dynamic_list_values($field, $entry, $field_value); } if ($field->form_id == $entry->form_id || empty($atts['embedded_field_id'])) { return self::display_value($field_value, $field, $atts); } // this is an embeded form $val = ''; if (strpos($atts['embedded_field_id'], 'form') === 0) { //this is a repeating section $child_entries = FrmEntry::getAll(array('it.parent_item_id' => $entry->id)); } else { // get all values for this field $child_values = isset($entry->metas[$atts['embedded_field_id']]) ? $entry->metas[$atts['embedded_field_id']] : false; if ($child_values) { $child_entries = FrmEntry::getAll(array('it.id' => (array) $child_values)); } } $field_value = array(); if (!isset($child_entries) || !$child_entries || !FrmAppHelper::pro_is_installed()) { return $val; } foreach ($child_entries as $child_entry) { $atts['item_id'] = $child_entry->id; $atts['post_id'] = $child_entry->post_id; // get the value for this field -- check for post values as well $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); if ($entry_val) { // foreach entry get display_value $field_value[] = self::display_value($entry_val, $field, $atts); } unset($child_entry); } $val = implode(', ', (array) $field_value); $val = wp_kses_post($val); return $val; }
unset($co); $v = FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($c['user_id'], 'user_login'), $charset, $to_encoding); unset($c); echo '"' . $v . '"' . $col_sep; $v = FrmProEntriesHelper::encode_value(FrmProAppHelper::get_formatted_time($comment->created_at, $wp_date_format, ' '), $charset, $to_encoding); echo '"' . $v . '"' . $col_sep; unset($v); } } if ($place_holder) { for ($i = 0; $i < $place_holder; $i++) { echo '""' . $col_sep . '""' . $col_sep . '""' . $col_sep; } unset($i); } unset($place_holder); $formatted_date = FrmProAppHelper::get_formatted_time($entry->created_at, $wp_date_format, ' '); echo '"' . $formatted_date . '"' . $col_sep; $formatted_date = FrmProAppHelper::get_formatted_time($entry->updated_at, $wp_date_format, ' '); echo '"' . $formatted_date . '"' . $col_sep; unset($formatted_date); echo '"' . FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($entry->user_id, 'user_login'), $charset, $to_encoding) . '"' . $col_sep; echo '"' . FrmProEntriesHelper::encode_value(FrmProFieldsHelper::get_display_name($entry->updated_by, 'user_login'), $charset, $to_encoding) . '"' . $col_sep; echo '"' . ($entry->is_draft ? '1' : '0') . '"' . $col_sep; echo '"' . $entry->ip . '"' . $col_sep; echo '"' . $entry->id . '"' . $col_sep; echo '"' . $entry->item_key . '"' . "\n"; unset($entry); } unset($entries); }