当前位置: 首页>>代码示例>>PHP>>正文


PHP RGFormsModel::get_lead_count方法代码示例

本文整理汇总了PHP中RGFormsModel::get_lead_count方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_lead_count方法的具体用法?PHP RGFormsModel::get_lead_count怎么用?PHP RGFormsModel::get_lead_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGFormsModel的用法示例。


在下文中一共展示了RGFormsModel::get_lead_count方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate_entry_limit

 /**
  * Validates the form's entry limit settings. Returns the entry limit message if entry limit exceeded.
  *
  * @param array $form current GF form object
  * @return string If entry limit exceeded returns entry limit setting.
  */
 public static function validate_entry_limit($form)
 {
     //If form has a limit of entries, check current entry count
     if (rgar($form, "limitEntries")) {
         $period = rgar($form, "limitEntriesPeriod");
         $range = self::get_limit_period_dates($period);
         $entry_count = RGFormsModel::get_lead_count($form['id'], "", null, null, $range["start_date"], $range["end_date"]);
         if ($entry_count >= $form["limitEntriesCount"]) {
             return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["limitEntriesMessage"]) . "</p>";
         }
     }
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:18,代码来源:form_display.php

示例2: start_export

 public static function start_export($form)
 {
     $form_id = $form["id"];
     $fields = $_POST["export_field"];
     $start_date = $_POST["export_date_start"];
     $end_date = $_POST["export_date_end"];
     //adding default fields
     array_push($form["fields"], array("id" => "id", "label" => __("Entry Id", "gravityforms")));
     array_push($form["fields"], array("id" => "date_created", "label" => __("Entry Date", "gravityforms")));
     array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "gravityforms")));
     array_push($form["fields"], array("id" => "source_url", "label" => __("Source Url", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
     array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
     $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
     $page_size = 200;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     //writing header
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = '"' . str_replace('"', '""', GFCommon::get_label($field, $field_id)) . '"';
         $lines .= "{$value},";
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 $long_text = "";
                 if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH) {
                     $long_text = RGFormsModel::get_field_value_long($lead["id"], $field_id);
                 }
                 $value = !empty($long_text) ? $long_text : $lead[$field_id];
                 $lines .= '"' . str_replace('"', '""', $value) . '",';
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:50,代码来源:export.php

示例3: validate_entry_limit

 /**
  * Validates the form's entry limit settings. Returns the entry limit message if entry limit exceeded.
  *
  * @param array $form current GF form object
  *
  * @return string If entry limit exceeded returns entry limit setting.
  */
 public static function validate_entry_limit($form)
 {
     //If form has a limit of entries, check current entry count
     if (rgar($form, 'limitEntries')) {
         $period = rgar($form, 'limitEntriesPeriod');
         $range = self::get_limit_period_dates($period);
         $entry_count = RGFormsModel::get_lead_count($form['id'], '', null, null, $range['start_date'], $range['end_date'], 'active');
         if ($entry_count >= $form['limitEntriesCount']) {
             return empty($form['limitEntriesMessage']) ? "<div class='gf_submission_limit_message'><p>" . esc_html__('Sorry. This form is no longer accepting new submissions.', 'gravityforms') . '</p></div>' : '<p>' . GFCommon::gform_do_shortcode($form['limitEntriesMessage']) . '</p>';
         }
     }
 }
开发者ID:timk85,项目名称:DIT,代码行数:19,代码来源:form_display.php

示例4: lead_detail_page

    public static function lead_detail_page()
    {
        global $wpdb;
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta($_GET["id"]);
        $form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
        $lead_id = rgget('lid');
        $filter = rgget("filter");
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $search = rgget("s");
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        // added status as an optional parameter to get_lead_count because the counts are inaccurate without using the status
        $lead_count = RGFormsModel::get_lead_count($form['id'], $search, $star, $read, null, null, $status);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $lead_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $lead_count) {
                $next_pos = false;
            }
        }
        // get the lead
        $leads = RGFormsModel::get_leads($form['id'], $sort_field, $sort_direction, $search, $position, 1, $star, $read, $is_numeric, null, null, $status);
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = RGFormsModel::get_lead($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your lead. Please try again", "gravityforms");
            return;
        }
        RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
        switch (RGForms::post("action")) {
            case "update":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::save_lead($form, $lead);
                do_action("gform_after_update_entry", $form, $lead["id"]);
                do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
                $lead = RGFormsModel::get_lead($lead["id"]);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case "add_note":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
                //emailing notes if configured
                if (rgpost("gentry_email_notes_to")) {
                    $email_to = $_POST["gentry_email_notes_to"];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST["gentry_email_subject"]);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    $result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
                }
                break;
            case "add_quick_note":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
                break;
            case "bulk":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST["bulk_action"] == "delete") {
                    RGFormsModel::delete_notes($_POST["note"]);
                }
                break;
            case "trash":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "trash");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "restore":
            case "unspam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "active");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "spam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "spam");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "delete":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::delete_lead($lead["id"]);
                ?>
                <script type="text/javascript">
                    document.location.href='<?php 
                echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
//.........这里部分代码省略.........
开发者ID:nikibrown,项目名称:2014-Nerd-presentation,代码行数:101,代码来源:entry_detail.php

示例5: leads_page

    public static function leads_page($form_id)
    {
        global $wpdb;
        //quit if version of wp is not supported
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post("action");
        $filter = rgget("filter");
        $search = rgget("s");
        $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
        $star = $filter == "star" ? 1 : null;
        // is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
        $read = $filter == "unread" ? 0 : null;
        //is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null;
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $update_message = "";
        switch ($action) {
            case "delete":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST["action_argument"];
                RGFormsModel::delete_lead($lead_id);
                $update_message = __("Entry deleted.", "gravityforms");
                break;
            case "bulk":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
                $select_all = rgpost("all_entries");
                $leads = empty($select_all) ? $_POST["lead"] : GFFormsModel::get_lead_ids($form_id, $search, $star, $read, null, null, $status);
                $entry_count = count($leads) > 1 ? sprintf(__("%d entries", "gravityforms"), count($leads)) : __("1 entry", "gravityforms");
                switch ($bulk_action) {
                    case "delete":
                        RGFormsModel::delete_leads($leads);
                        $update_message = sprintf(__("%s deleted.", "gravityforms"), $entry_count);
                        break;
                    case "trash":
                        RGFormsModel::update_leads_property($leads, "status", "trash");
                        $update_message = sprintf(__("%s moved to Trash.", "gravityforms"), $entry_count);
                        break;
                    case "restore":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the Trash.", "gravityforms"), $entry_count);
                        break;
                    case "unspam":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the spam.", "gravityforms"), $entry_count);
                        break;
                    case "spam":
                        RGFormsModel::update_leads_property($leads, "status", "spam");
                        $update_message = sprintf(__("%s marked as spam.", "gravityforms"), $entry_count);
                        break;
                    case "mark_read":
                        RGFormsModel::update_leads_property($leads, "is_read", 1);
                        $update_message = sprintf(__("%s marked as read.", "gravityforms"), $entry_count);
                        break;
                    case "mark_unread":
                        RGFormsModel::update_leads_property($leads, "is_read", 0);
                        $update_message = sprintf(__("%s marked as unread.", "gravityforms"), $entry_count);
                        break;
                    case "add_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 1);
                        $update_message = sprintf(__("%s starred.", "gravityforms"), $entry_count);
                        break;
                    case "remove_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 0);
                        $update_message = sprintf(__("%s unstarred.", "gravityforms"), $entry_count);
                        break;
                }
                break;
            case "change_columns":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $columns = GFCommon::json_decode(stripslashes($_POST["grid_columns"]), true);
                RGFormsModel::update_grid_column_meta($form_id, $columns);
                break;
        }
        if (rgpost("button_delete_permanently")) {
            RGFormsModel::delete_leads_by_form($form_id, $filter);
        }
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
        $form = RGFormsModel::get_form_meta($form_id);
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $page_size = apply_filters("gform_entry_page_size", apply_filters("gform_entry_page_size_{$form_id}", 20, $form_id), $form_id);
        $first_item_index = $page_index * $page_size;
        $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric, null, null, $status);
        $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read, null, null, $status);
        $summary = RGFormsModel::get_form_counts($form_id);
        $active_lead_count = $summary["total"];
        $unread_count = $summary["unread"];
        $starred_count = $summary["starred"];
        $spam_count = $summary["spam"];
        $trash_count = $summary["trash"];
        $columns = RGFormsModel::get_grid_columns($form_id, true);
        $search_qs = empty($search) ? "" : "&s=" . urlencode($search);
        $sort_qs = empty($sort_field) ? "" : "&sort={$sort_field}";
        $dir_qs = empty($sort_field) ? "" : "&dir={$sort_direction}";
        $star_qs = $star !== null ? "&star={$star}" : "";
        $read_qs = $read !== null ? "&read={$read}" : "";
//.........这里部分代码省略.........
开发者ID:nikibrown,项目名称:2014-Nerd-presentation,代码行数:101,代码来源:entry_list.php

示例6: get_form

 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
 {
     //looking up form id by form name
     if (!is_numeric($form_id)) {
         $form_id = RGFormsModel::get_form_id($form_id);
     }
     //reading form metadata
     $form = RGFormsModel::get_form_meta($form_id, true);
     $form = RGFormsModel::add_default_properties($form);
     //disable ajax if form has a reCAPTCHA field (not supported).
     if ($ajax && self::has_recaptcha_field($form)) {
         $ajax = false;
     }
     $is_postback = false;
     $is_valid = true;
     $confirmation_message = "";
     $page_number = 1;
     //If form was submitted, read variables set during form submission procedure
     $submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
     if ($submission_info) {
         $is_postback = true;
         $is_valid = $submission_info["is_valid"] || rgget("is_confirmation", $submission_info);
         $form = $submission_info["form"];
         $lead = $submission_info["lead"];
         $confirmation_message = rgget("confirmation_message", $submission_info);
         if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
             if ($submission_info["page_number"] == 0) {
                 //post submission hook
                 do_action("gform_post_submission", $lead, $form);
                 do_action("gform_post_submission_{$form["id"]}", $lead, $form);
             } else {
                 //change page hook
                 do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
                 do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
             }
         }
     } else {
         if (!current_user_can("administrator")) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (rgar($form, "enableHoneypot")) {
         $form["fields"][] = self::get_honeypot_field($form);
     }
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
     if ($form == null) {
         return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
     }
     $has_pages = self::has_pages($form);
     //calling tab index filter
     GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", $tabindex, $form), $form);
     //Don't display inactive forms
     if (!$force_display && !$is_postback) {
         $form_info = RGFormsModel::get_form($form_id);
         if (!$form_info->is_active) {
             return "";
         }
         //If form has a schedule, make sure it is within the configured start and end dates
         if (rgar($form, "scheduleForm")) {
             $local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
             $local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
             $timestamp_start = strtotime($local_time_start . ' +0000');
             $timestamp_end = strtotime($local_time_end . ' +0000');
             $now = current_time("timestamp");
             if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
                 return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["scheduleMessage"]) . "</p>";
             }
         }
         //If form has a limit of entries, check current entry count
         if (rgar($form, "limitEntries")) {
             $period = rgar($form, "limitEntriesPeriod");
             $range = self::get_limit_period_dates($period);
             $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $range["start_date"], $range["end_date"]);
             if ($entry_count >= $form["limitEntriesCount"]) {
                 return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["limitEntriesMessage"]) . "</p>";
             }
         }
         // If form requires login, check if user is logged in
         if (rgar($form, "requireLogin")) {
             if (!is_user_logged_in()) {
                 return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
             }
         }
     }
     $form_string = "";
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form, $ajax);
     if (empty($confirmation_message)) {
         $wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
         if (!$is_valid) {
             $wrapper_css_class .= " gform_validation_error";
         }
         //Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : "";
         $form_string .= "\n                <div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
         $action = add_query_arg(array());
         $default_anchor = $has_pages || $ajax ? true : false;
         $use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
//.........这里部分代码省略.........
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:101,代码来源:form_display.php

示例7: start_export

 public static function start_export($form)
 {
     $form_id = $form["id"];
     $fields = $_POST["export_field"];
     $start_date = $_POST["export_date_start"];
     $end_date = $_POST["export_date_end"];
     //adding default fields
     array_push($form["fields"], array("id" => "created_by", "label" => __("Created By (User Id)", "gravityforms")));
     array_push($form["fields"], array("id" => "id", "label" => __("Entry Id", "gravityforms")));
     array_push($form["fields"], array("id" => "date_created", "label" => __("Entry Date", "gravityforms")));
     array_push($form["fields"], array("id" => "source_url", "label" => __("Source Url", "gravityforms")));
     array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_amount", "label" => __("Payment Amount", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
     array_push($form["fields"], array("id" => "post_id", "label" => __("Post Id", "gravityforms")));
     array_push($form["fields"], array("id" => "user_agent", "label" => __("User Agent", "gravityforms")));
     array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "gravityforms")));
     $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
     $page_size = 200;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     // set the separater
     $separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
     $field_rows = self::get_field_row_count($form, $fields, $entry_count);
     //writing header
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
         $subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
         if ($subrow_count == 0) {
             $lines .= '"' . $value . '"' . $separator;
         } else {
             for ($i = 1; $i <= $subrow_count; $i++) {
                 $lines .= '"' . $value . " " . $i . '"' . $separator;
             }
         }
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 switch ($field_id) {
                     case "date_created":
                         $lead_gmt_time = mysql2date("G", $lead["date_created"]);
                         $lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
                         $value = date_i18n("Y-m-d H:i:s", $lead_local_time);
                         break;
                     default:
                         $long_text = "";
                         if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH - 10) {
                             $long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
                         }
                         $value = !empty($long_text) ? $long_text : $lead[$field_id];
                         break;
                 }
                 if (isset($field_rows[$field_id])) {
                     $list = empty($value) ? array() : unserialize($value);
                     foreach ($list as $row) {
                         $row_values = array_values($row);
                         $row_str = implode("|", $row_values);
                         $lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
                     }
                     //filling missing subrow columns (if any)
                     $missing_count = intval($field_rows[$field_id]) - count($list);
                     for ($i = 0; $i < $missing_count; $i++) {
                         $lines .= '""' . $separator;
                     }
                 } else {
                     $value = maybe_unserialize($value);
                     if (is_array($value)) {
                         $value = implode("|", $value);
                     }
                     $lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
                 }
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
开发者ID:xeyefex,项目名称:Mixd-WordPress-Framework,代码行数:91,代码来源:export.php

示例8: leads_page

    public static function leads_page($form_id)
    {
        global $wpdb;
        //quit if version of wp is not supported
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post("action");
        switch ($action) {
            case "delete":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST["action_argument"];
                RGFormsModel::delete_lead($lead_id);
                break;
            case "bulk":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
                $leads = $_POST["lead"];
                switch ($bulk_action) {
                    case "delete":
                        RGFormsModel::delete_leads($leads);
                        break;
                    case "mark_read":
                        RGFormsModel::update_leads_property($leads, "is_read", 1);
                        break;
                    case "mark_unread":
                        RGFormsModel::update_leads_property($leads, "is_read", 0);
                        break;
                    case "add_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 1);
                        break;
                    case "remove_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 0);
                        break;
                }
                break;
            case "change_columns":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $columns = GFCommon::json_decode(stripslashes($_POST["grid_columns"]), true);
                RGFormsModel::update_grid_column_meta($form_id, $columns);
                break;
        }
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
        $search = RGForms::get("s");
        $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
        $star = is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
        $read = is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null;
        $page_size = 20;
        $first_item_index = $page_index * $page_size;
        $form = RGFormsModel::get_form_meta($form_id);
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric);
        $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read);
        $summary = RGFormsModel::get_form_counts($form_id);
        $total_lead_count = $summary["total"];
        $unread_count = $summary["unread"];
        $starred_count = $summary["starred"];
        $columns = RGFormsModel::get_grid_columns($form_id, true);
        $search_qs = empty($search) ? "" : "&s=" . urlencode($search);
        $sort_qs = empty($sort_field) ? "" : "&sort={$sort_field}";
        $dir_qs = empty($sort_field) ? "" : "&dir={$sort_direction}";
        $star_qs = $star !== null ? "&star={$star}" : "";
        $read_qs = $read !== null ? "&read={$read}" : "";
        $page_links = paginate_links(array('base' => admin_url("admin.php") . "?page=gf_entries&view=entries&id={$form_id}&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs, 'format' => 'paged=%#%', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($lead_count / $page_size), 'current' => $page_index + 1, 'show_all' => false));
        wp_print_scripts(array("thickbox"));
        wp_print_styles(array("thickbox"));
        ?>

        <script src="<?php 
        echo GFCommon::get_base_url();
        ?>
/js/jquery.json-1.3.js?ver=<?php 
        echo GFCommon::$version;
        ?>
"></script>

        <script>
            function ChangeColumns(columns){
                jQuery("#action").val("change_columns");
                jQuery("#grid_columns").val(jQuery.toJSON(columns));
                tb_remove();
                jQuery("#lead_form")[0].submit();
            }

            function Search(sort_field_id, sort_direction, form_id, search, star, read){
                var search_qs = search == "" ? "" : "&s=" + search;
                var star_qs = star == "" ? "" : "&star=" + star;
                var read_qs = read == "" ? "" : "&read=" + read;

                var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs;
                document.location = location;
            }

            function ToggleStar(img, lead_id){
                var is_starred = img.src.indexOf("star1.png") >=0
                if(is_starred)
                    img.src = img.src.replace("star1.png", "star0.png");
//.........这里部分代码省略.........
开发者ID:hypenotic,项目名称:slowfood,代码行数:101,代码来源:entry_list.php

示例9: start_export

 public static function start_export($form)
 {
     $form_id = $form["id"];
     $fields = $_POST["export_field"];
     $start_date = empty($_POST["export_date_start"]) ? "" : self::get_gmt_date($_POST["export_date_start"] . " 00:00");
     $end_date = empty($_POST["export_date_end"]) ? "" : self::get_gmt_date($_POST["export_date_end"] . " 23:59:59");
     GFCommon::log_debug("start date: {$start_date}");
     GFCommon::log_debug("end date: {$end_date}");
     $form = self::add_default_export_fields($form);
     $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
     $page_size = 200;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     // set the separater
     $separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
     $field_rows = self::get_field_row_count($form, $fields, $entry_count);
     //writing header
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
         $subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
         if ($subrow_count == 0) {
             $lines .= '"' . $value . '"' . $separator;
         } else {
             for ($i = 1; $i <= $subrow_count; $i++) {
                 $lines .= '"' . $value . " " . $i . '"' . $separator;
             }
         }
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 switch ($field_id) {
                     case "date_created":
                         $lead_gmt_time = mysql2date("G", $lead["date_created"]);
                         $lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
                         $value = date_i18n("Y-m-d H:i:s", $lead_local_time, true);
                         break;
                     default:
                         $long_text = "";
                         if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH - 10) {
                             $long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
                         }
                         $value = !empty($long_text) ? $long_text : $lead[$field_id];
                         $value = apply_filters("gform_export_field_value", $value, $form_id, $field_id, $lead);
                         break;
                 }
                 if (isset($field_rows[$field_id])) {
                     $list = empty($value) ? array() : unserialize($value);
                     foreach ($list as $row) {
                         $row_values = array_values($row);
                         $row_str = implode("|", $row_values);
                         $lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
                     }
                     //filling missing subrow columns (if any)
                     $missing_count = intval($field_rows[$field_id]) - count($list);
                     for ($i = 0; $i < $missing_count; $i++) {
                         $lines .= '""' . $separator;
                     }
                 } else {
                     $value = maybe_unserialize($value);
                     if (is_array($value)) {
                         $value = implode("|", $value);
                     }
                     $lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
                 }
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
开发者ID:rainrose,项目名称:WoodsDev,代码行数:83,代码来源:export.php

示例10: get_form

 public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null)
 {
     //reading form metadata
     $form = RGFormsModel::get_form_meta($form_id);
     //Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
     $form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
     if ($form == null) {
         return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
     }
     //Don't display inactive forms
     if (!$force_display) {
         $form_info = RGFormsModel::get_form($form_id);
         if (!$form_info->is_active) {
             return "";
         }
         //If form has a schedule, make sure it is within the configured start and end dates
         if ($form["scheduleForm"]) {
             $local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
             $local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
             $timestamp_start = strtotime($local_time_start . ' +0000');
             $timestamp_end = strtotime($local_time_end . ' +0000');
             $now = current_time("timestamp");
             if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
                 return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . $form["scheduleMessage"] . "</p>";
             }
         }
         //If form has a limit of entries, check current entry count
         if ($form["limitEntries"]) {
             $entry_count = RGFormsModel::get_lead_count($form_id, "");
             if ($entry_count >= $form["limitEntriesCount"]) {
                 return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . $form["limitEntriesMessage"] . "</p>";
             }
         }
     }
     $form_string = "";
     //When called via a template, this will enqueue the proper scripts
     //When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
     self::enqueue_form_scripts($form);
     //handling postback if form was submitted
     $is_postback = $_POST["is_submit_" . $form_id];
     $is_valid = true;
     if ($is_postback) {
         $is_valid = self::validate($form, $field_values);
         if ($is_valid) {
             //pre submission action
             do_action("gform_pre_submission", $form);
             //pre submission filter
             $form = apply_filters("gform_pre_submission_filter", $form);
             //handle submission
             $lead = array();
             $confirmation_message = self::handle_submission($form, $lead);
             //post submission hook
             do_action("gform_post_submission", $lead, $form);
         }
     } else {
         //recording form view. Ignores views from administrators
         if (!current_user_can("administrator")) {
             RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
         }
     }
     if (empty($confirmation_message)) {
         //Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
         $style = self::has_conditional_logic($form) ? "style='display:none'" : "";
         $form_string .= "\n                <div class='gform_wrapper' id='gform_wrapper_{$form_id}' " . $style . ">\n                <form method='post' enctype='multipart/form-data' id='gform_{$form_id}' class='" . $form["cssClass"] . "' action=''>";
         if ($display_title || $display_description) {
             $form_string .= "\n                        <div class='gform_heading'>";
             if ($display_title) {
                 $form_string .= "\n                            <h3 class='gform_title'>" . $form['title'] . "</h3>";
             }
             if ($display_description) {
                 $form_string .= "\n                            <span class='gform_description'>" . $form['description'] . "</span>";
             }
             $form_string .= "\n                        </div>";
         }
         if ($is_postback && !$is_valid) {
             $validation_message = "<div class='validation_error'>" . __("There was a problem with your submission.", "gravityforms") . "<br /> " . __("Errors have been highlighted below ", "gravityforms") . "</div>";
             $form_string .= apply_filters("gform_validation_message", $validation_message, $form);
         }
         $form_string .= "\n                        <div class='gform_body'>\n                            <input type='hidden' class='gform_hidden' name='is_submit_{$form_id}' value='1'/>\n                            <ul id='gform_fields_{$form_id}' class='gform_fields " . $form['labelPlacement'] . "'>";
         if (is_array($form['fields'])) {
             foreach ($form['fields'] as $field) {
                 $field["conditionalLogicFields"] = self::get_conditional_logic_fields($form, $field["id"]);
                 $form_string .= self::get_field($field, RGFormsModel::get_field_value($field, $field_values), false, $form, $field_values);
             }
         }
         $form_string .= "\n                            </ul>\n                        </div>\n                        <div class='gform_footer " . $form['labelPlacement'] . "'>";
         $tabindex = GFCommon::$tab_index++;
         if ($form["button"]["type"] == "text" || empty($form["button"]["imageUrl"])) {
             $button_text = empty($form["button"]["text"]) ? __("Submit", "gravityforms") : $form["button"]["text"];
             $button_input = "<input type='submit' class='button' value='" . esc_attr($button_text) . "' tabindex='{$tabindex}'/>";
         } else {
             $imageUrl = $form["button"]["imageUrl"];
             $button_input = "<input type='image' src='{$imageUrl}' tabindex='{$tabindex}'/>";
         }
         $button_input = apply_filters("gform_submit_button", $button_input, $form);
         $button_input = apply_filters("gform_submit_button_{$form_id}", $button_input, $form);
         $form_string .= $button_input;
         if (current_user_can("gform_full_access")) {
             $form_string .= "&nbsp;&nbsp;<a href='" . get_bloginfo("wpurl") . "/wp-admin/admin.php?page=gf_edit_forms&amp;id=" . $form_id . "'>" . __("Edit this form", "gravityforms") . "</a>";
         }
//.........这里部分代码省略.........
开发者ID:812studio,项目名称:812studio,代码行数:101,代码来源:form_display.php


注:本文中的RGFormsModel::get_lead_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。