コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: mb_advanced.php プロジェクト: swc-dng/swcsandbox
"></span>
        </td>
        <td>
            <div id="frm_where_options" class="frm_add_remove">
                <a href="javascript:void(0)" class="frm_add_where_row button" style="<?php 
echo empty($post->frm_where) ? '' : 'display:none';
?>
">+ <?php 
_e('Add', 'formidable');
?>
</a>
                <div class="frm_logic_rows">
            <?php 
foreach ($post->frm_where as $where_key => $where_field) {
    if (isset($post->frm_where_is[$where_key]) && isset($post->frm_where_val[$where_key])) {
        FrmProDisplaysController::add_where_row($where_key, $post->frm_form_id, $where_field, $post->frm_where_is[$where_key], $post->frm_where_val[$where_key]);
    }
}
?>
                </div>
            </div>
        </td>
    </tr>

    <tr class="form-field">
        <td><?php 
_e('No Entries Message', 'formidable');
?>
</td>
        <td>
            <textarea id="empty_msg" name="options[empty_msg]" style="width:98%"><?php 
コード例 #3
0
ファイル: where_row.php プロジェクト: amit0773/manaslake
</option>
        <option value="LIKE" <?php 
selected($where_is, 'LIKE');
?>
><?php 
_e('like', 'formidable');
?>
</option>
        <option value="not LIKE" <?php 
selected($where_is, 'not LIKE');
?>
><?php 
_e('NOT like', 'formidable');
?>
</option>
    </select>
    <span id="where_field_options_<?php 
echo $where_key;
?>
" style="display:inline;">
        <?php 
FrmProDisplaysController::add_where_options($where_field, $where_key, $where_val);
?>
    </span>
    <a class="frm_remove_tag frm_icon_font" data-removeid="frm_where_field_<?php 
echo $where_key;
?>
" data-showlast="#frm_where_options .frm_add_where_row"></a>
    <a class="frm_add_where_row frm_add_tag frm_icon_font"></a>
    
</div>
コード例 #4
0
 public static function activation_install()
 {
     // make sure post type exists before creating any views
     FrmProDisplaysController::register_post_types();
     self::install();
 }
コード例 #5
0
 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;
 }
コード例 #6
0
<div id="frm_adv_info" class="postbox">
    <div class="handlediv" title="<?php 
_e('Click to toggle', 'formidable');
?>
"><br/></div><h3 class="hndle"><span><?php 
_e('Customization', 'formidable');
?>
</span></h3>
    <div class="inside">
    <?php 
if ($frm_vars['pro_is_installed']) {
    FrmProDisplaysController::mb_tags_box($id);
} else {
    ?>
        <div id="taxonomy-linkcategory" class="categorydiv">
            <ul id="category-tabs" class="category-tabs frm-category-tabs">
        		<li class="tabs" ><a href="#frm-insert-fields-box" id="frm_insert_fields_tab" ><?php 
    _e('Insert Fields', 'formidable');
    ?>
</a></li>
        		<li class="hide-if-no-js"><a href="#frm-html-tags" id="frm_html_tags_tab" ><?php 
    _e('HTML Tags', 'formidable');
    ?>
</a></li>
        	</ul>
        	<div id="frm-insert-fields-box" class="tabs-panel" style="max-height:none;padding-right:0;">
        	    <br/><br/>
                <?php 
    FrmAppController::update_message('insert field values into your messages');
    ?>
        	</div>
コード例 #7
0
    } else {
        ?>
                <p class="info">
                    참가신청를 하려면 
                    <a href="<?php 
        echo wp_login_url(get_permalink() . '#attendants');
        ?>
" title="Login">로그인</a>
                    하세요!
                </p>    
            <?php 
    }
    ?>
            
            <?php 
    echo FrmProDisplaysController::get_shortcode(array('id' => 97));
    ?>
        </div>    
        
        <?php 
    /*
     * Include the post format-specific template for the content. If you want to
     * use this in a child theme, then include a file called called content-___.php
     * (where ___ is the post format) and that will be used instead.
     */
    // get_template_part( 'content', 'moim' );
    // If comments are open or we have at least one comment, load up the comment template.
    if (comments_open() || get_comments_number()) {
        comments_template();
    }
    // Previous/next post navigation.
コード例 #8
0
ファイル: formidable-pro.php プロジェクト: amit0773/manaslake
require $frm_path . '/pro/classes/models/FrmProEntryMeta.php';
require $frm_path . '/pro/classes/models/FrmProField.php';
require $frm_path . '/pro/classes/models/FrmProForm.php';
require $frm_path . '/pro/classes/models/FrmProNotification.php';
global $frmpro_display;
$frmpro_display = new FrmProDisplay();
$obj = new FrmProNotification();
// Instansiate Controllers
require $frm_path . '/pro/classes/controllers/FrmProAppController.php';
require $frm_path . '/pro/classes/controllers/FrmProDisplaysController.php';
require $frm_path . '/pro/classes/controllers/FrmProEntriesController.php';
require $frm_path . '/pro/classes/controllers/FrmProFieldsController.php';
require $frm_path . '/pro/classes/controllers/FrmProFormsController.php';
require $frm_path . '/pro/classes/controllers/FrmProStatisticsController.php';
FrmProAppController::load_hooks();
FrmProDisplaysController::load_hooks();
FrmProEntriesController::load_hooks();
FrmProFieldsController::load_hooks();
FrmProFormsController::load_hooks();
FrmProStatisticsController::load_hooks();
FrmProSettingsController::load_hooks();
if (is_admin()) {
    require $frm_path . '/pro/classes/controllers/FrmProXMLController.php';
    FrmProXMLController::load_hooks();
}
if (is_multisite()) {
    //Models
    require $frm_path . '/pro/classes/models/FrmProCopy.php';
    $obj = new FrmProCopy();
    //Add options to copy forms and displays
    require $frm_path . '/pro/classes/controllers/FrmProCopiesController.php';