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


PHP GFCommon::is_product_field方法代码示例

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


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

示例1: has_price_field

 private static function has_price_field($form)
 {
     $has_price_field = false;
     foreach ($form['fields'] as $field) {
         $input_type = GFFormsModel::get_input_type($field);
         $has_price_field = GFCommon::is_product_field($input_type) ? true : $has_price_field;
     }
     return $has_price_field;
 }
开发者ID:timk85,项目名称:DIT,代码行数:9,代码来源:form_display.php

示例2: get_form_fields

 /**
  * Return array of fields' id and label, for a given Form ID
  *
  * @access public
  * @param string|array $form_id (default: '') or $form object
  * @return array
  */
 public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true)
 {
     if (!is_array($form)) {
         $form = self::get_form($form);
     }
     $fields = array();
     $has_product_fields = false;
     $has_post_fields = false;
     $has_quiz_fields = false;
     $has_poll_fields = false;
     // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated.
     if (false === class_exists('GF_Field') && $add_default_properties) {
         $form = RGFormsModel::add_default_properties($form);
     }
     if ($form) {
         foreach ($form['fields'] as $field) {
             if ($include_parent_field || empty($field['inputs'])) {
                 $fields[$field['id']] = array('label' => rgar($field, 'label'), 'parent' => null, 'type' => rgar($field, 'type'), 'adminLabel' => rgar($field, 'adminLabel'), 'adminOnly' => rgar($field, 'adminOnly'));
             }
             if ($add_default_properties && !empty($field['inputs'])) {
                 foreach ($field['inputs'] as $input) {
                     /**
                      * @hack
                      * In case of email/email confirmation, the input for email has the same id as the parent field
                      */
                     if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) {
                         continue;
                     }
                     $fields[(string) $input['id']] = array('label' => rgar($input, 'label'), 'customLabel' => rgar($input, 'customLabel'), 'parent' => $field, 'type' => rgar($field, 'type'), 'adminLabel' => rgar($field, 'adminLabel'), 'adminOnly' => rgar($field, 'adminOnly'));
                 }
             }
             /**
              * @since 1.8
              */
             if ('quiz' === $field['type']) {
                 $has_quiz_fields = true;
             }
             /**
              * @since 1.8
              */
             if ('poll' === $field['type']) {
                 $has_poll_fields = true;
             }
             if (GFCommon::is_product_field($field['type'])) {
                 $has_product_fields = true;
             }
             /**
              * @hack Version 1.9
              */
             $field_for_is_post_field = class_exists('GF_Fields') ? (object) $field : (array) $field;
             if (GFCommon::is_post_field($field_for_is_post_field)) {
                 $has_post_fields = true;
             }
         }
     }
     /**
      * @since 1.7
      */
     if ($has_post_fields) {
         $fields['post_id'] = array('label' => __('Post ID', 'gravityview'), 'type' => 'post_id');
     }
     if ($has_product_fields) {
         $fields['payment_status'] = array('label' => __('Payment Status', 'gravityview'), 'type' => 'payment_status');
         $fields['payment_date'] = array('label' => __('Payment Date', 'gravityview'), 'type' => 'payment_date');
         $fields['payment_amount'] = array('label' => __('Payment Amount', 'gravityview'), 'type' => 'payment_amount');
         $fields['payment_method'] = array('label' => __('Payment Method', 'gravityview'), 'type' => 'payment_method');
         $fields['is_fulfilled'] = array('label' => __('Is Fulfilled', 'gravityview'), 'type' => 'is_fulfilled');
         $fields['transaction_id'] = array('label' => __('Transaction ID', 'gravityview'), 'type' => 'transaction_id');
         $fields['transaction_type'] = array('label' => __('Transaction Type', 'gravityview'), 'type' => 'transaction_type');
     }
     /**
      * @since 1.8
      */
     if ($has_quiz_fields) {
         $fields['gquiz_score'] = array('label' => __('Quiz Score Total', 'gravityview'), 'type' => 'quiz_score', 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_percent'] = array('label' => __('Quiz Percentage Grade', 'gravityview'), 'type' => 'quiz_percent', 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_grade'] = array('label' => __('Quiz Letter Grade', 'gravityview'), 'type' => 'quiz_grade', 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'));
         $fields['gquiz_is_pass'] = array('label' => __('Quiz Pass/Fail', 'gravityview'), 'type' => 'quiz_is_pass', 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'));
     }
     return $fields;
 }
开发者ID:roarmoser,项目名称:gv1,代码行数:88,代码来源:class-common.php

示例3: lead_detail_grid

    public static function lead_detail_grid($form, $lead, $allow_display_empty_fields = false)
    {
        $form_id = $form["id"];
        $display_empty_fields = false;
        if ($allow_display_empty_fields) {
            $display_empty_fields = rgget("gf_display_empty_fields", $_COOKIE);
        }
        ?>
        <table cellspacing="0" class="widefat fixed entry-detail-view">
            <thead>
                <tr>
                    <th id="details">
                    <?php 
        echo $form["title"];
        ?>
 : <?php 
        _e("Entry # ", "gravityforms");
        ?>
 <?php 
        echo $lead["id"];
        ?>
                    </th>
                    <th style="width:140px; font-size:10px; text-align: right;">
                    <?php 
        if ($allow_display_empty_fields) {
            ?>
                            <input type="checkbox" id="gentry_display_empty_fields" <?php 
            echo $display_empty_fields ? "checked='checked'" : "";
            ?>
 onclick="ToggleShowEmptyFields();"/>&nbsp;&nbsp;<label for="gentry_display_empty_fields"><?php 
            _e("show empty fields", "gravityforms");
            ?>
</label>
                            <?php 
        }
        ?>
                    </th>
                </tr>
            </thead>
            <tbody>
                <?php 
        $count = 0;
        $field_count = sizeof($form["fields"]);
        $has_product_fields = false;
        foreach ($form["fields"] as $field) {
            switch (RGFormsModel::get_input_type($field)) {
                case "section":
                    if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields) {
                        $count++;
                        $is_last = $count >= $field_count ? true : false;
                        ?>
                                <tr>
                                    <td colspan="2" class="entry-view-section-break<?php 
                        echo $is_last ? " lastrow" : "";
                        ?>
"><?php 
                        echo esc_html(GFCommon::get_label($field));
                        ?>
</td>
                                </tr>
                                <?php 
                    }
                    break;
                case "captcha":
                case "html":
                case "password":
                case "page":
                    //ignore captcha, html, password, page field
                    break;
                default:
                    //ignore product fields as they will be grouped together at the end of the grid
                    if (GFCommon::is_product_field($field["type"])) {
                        $has_product_fields = true;
                        continue;
                    }
                    $value = RGFormsModel::get_lead_field_value($lead, $field);
                    $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]);
                    $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form);
                    if ($display_empty_fields || !empty($display_value) || $display_value === "0") {
                        $count++;
                        $is_last = $count >= $field_count && !$has_product_fields ? true : false;
                        $last_row = $is_last ? " lastrow" : "";
                        $display_value = empty($display_value) && $display_value !== "0" ? "&nbsp;" : $display_value;
                        $content = '
                                <tr>
                                    <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td>
                                </tr>';
                        $content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]);
                        echo $content;
                    }
                    break;
            }
        }
        $products = array();
        if ($has_product_fields) {
            $products = GFCommon::get_product_fields($form, $lead);
            if (!empty($products["products"])) {
//.........这里部分代码省略.........
开发者ID:JSpier,项目名称:smacamp,代码行数:101,代码来源:entry_detail.php

示例4: export_feed

 public function export_feed($entry, $form, $feed)
 {
     //$email       = $entry[ $feed['meta']['listFields_email'] ];
     //$name        = '';
     if (!empty($feed['meta']['listFields_first_name'])) {
         $name = $this->get_name($entry, $feed['meta']['listFields_first_name']);
     }
     $merge_vars = array();
     $field_maps = $this->get_field_map_fields($feed, 'listFields');
     foreach ($field_maps as $var_key => $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         if (GFCommon::is_product_field($field['type']) && rgar($field, 'enablePrice')) {
             $ary = explode('|', $entry[$field_id]);
             $product_name = count($ary) > 0 ? $ary[0] : '';
             $merge_vars[] = array('name' => $var_key, 'value' => $product_name);
         } else {
             if (RGFormsModel::get_input_type($field) == 'checkbox') {
                 foreach ($field['inputs'] as $input) {
                     $index = (string) $input['id'];
                     $merge_vars[] = array('name' => $var_key, 'value' => apply_filters('gform_crm_field_value', rgar($entry, $index), $form['id'], $field_id, $entry));
                 }
             } else {
                 $merge_vars[] = array('name' => $var_key, 'value' => apply_filters('gform_crm_field_value', rgar($entry, $field_id), $form['id'], $field_id, $entry));
             }
         }
     }
     $override_custom_fields = apply_filters('gform_crm_override_blank_custom_fields', false, $entry, $form, $feed);
     if (!$override_custom_fields) {
         $merge_vars = $this->remove_blank_custom_fields($merge_vars);
     }
     $settings = $this->get_plugin_settings();
     if (isset($settings['gf_fd_accountname'])) {
         $accountname = $settings['gf_fd_accountname'];
     } else {
         $accountname = "";
     }
     if (isset($settings['gf_fd_apipassword'])) {
         $apipassword = $settings['gf_fd_apipassword'];
     } else {
         $apipassword = "";
     }
     $id = $this->facturadirecta_createlead($accountname, $apipassword, $merge_vars);
     //Sends email if it does not create a lead
     //if ($id == false)
     //    $this->send_emailerrorlead($crm_type);
     $this->debugcrm($id);
 }
开发者ID:davidperezgar,项目名称:gravityforms-facturadirecta,代码行数:47,代码来源:class-gf-facturadirecta.php

示例5: modify_edit_field_input

 /**
  *
  * Fill-in the saved values into the form inputs
  *
  * @param string $field_content Always empty.
  * @param GF_Field $field
  * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
  * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
  * @param int $form_id Form ID
  *
  * @return mixed
  */
 function modify_edit_field_input($field_content = '', $field, $value, $lead_id = 0, $form_id)
 {
     // If the form has been submitted, then we don't need to pre-fill the values,
     // Except for fileupload type - run always!!
     if ($this->is_edit_entry_submission() && 'fileupload' !== $field->type || GFCommon::is_product_field($field->type)) {
         return $field_content;
     }
     // Turn on Admin-style display for file upload fields only
     if ('fileupload' === $field->type) {
         $_GET['page'] = 'gf_entries';
     }
     // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
     $field->adminOnly = false;
     /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
     // add categories as choices for Post Category field
     if ('post_category' === $field->type) {
         $field = GFCommon::add_categories_as_choices($field, $value);
     }
     /**
      * @filter `gravityview/edit_entry/pre_populate/override` Allow the pre-populated value to override saved value in Edit Entry form. By default, pre-populate mechanism only kicks on empty fields.
      * @param boolean True: override saved values; False: don't override (default)
      * @param $field GF_Field object Gravity Forms field object
      * @since 1.13
      */
     $override_saved_value = apply_filters('gravityview/edit_entry/pre_populate/override', false, $field);
     // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
     if (isset($field->inputs) && is_array($field->inputs) && !in_array($field->type, array('time', 'date'))) {
         $field_value = array();
         // only accept pre-populated values if the field doesn't have any choice selected.
         $allow_pre_populated = $field->allowsPrepopulate;
         foreach ((array) $field->inputs as $input) {
             $input_id = strval($input['id']);
             if (!empty($this->entry[$input_id])) {
                 $field_value[$input_id] = 'post_category' === $field->type ? GFCommon::format_post_category($this->entry[$input_id], true) : $this->entry[$input_id];
                 $allow_pre_populated = false;
             }
         }
         $pre_value = $field->get_value_submission(array(), false);
         $field_value = !$allow_pre_populated && !($override_saved_value && !empty($pre_value)) ? $field_value : $pre_value;
     } else {
         $id = intval($field->id);
         // get pre-populated value if exists
         $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value($field->inputName, array(), $field) : '';
         // saved field entry value (if empty, fallback to the pre-populated value, if exists)
         // or pre-populated value if not empty and set to override saved value
         $field_value = !empty($this->entry[$id]) && !($override_saved_value && !empty($pre_value)) ? $this->entry[$id] : $pre_value;
         // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
         if ('post_category' === $field->type && !empty($field_value)) {
             $categories = array();
             foreach (explode(',', $field_value) as $cat_string) {
                 $categories[] = GFCommon::format_post_category($cat_string, true);
             }
             $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode('', $categories);
         }
     }
     // if value is empty get the default value if defined
     $field_value = $field->get_value_default_if_empty($field_value);
     /**
      * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
      * @since 1.11
      * @param mixed $field_value field value used to populate the input
      * @param object $field Gravity Forms field object ( Class GF_Field )
      */
     $field_value = apply_filters('gravityview/edit_entry/field_value', $field_value, $field);
     // Prevent any PHP warnings, like undefined index
     ob_start();
     $return = $field->get_field_input($this->form, $field_value, $this->entry);
     // If there was output, it's an error
     $warnings = ob_get_clean();
     if (!empty($warnings)) {
         do_action('gravityview_log_error', __METHOD__ . $warnings, $field_value);
     }
     /**
      * Unset hack $_GET['page'] = 'gf_entries'
      * We need the fileupload html field to render with the proper id
      *  ( <li id="field_80_16" ... > )
      */
     unset($_GET['page']);
     return $return;
 }
开发者ID:hansstam,项目名称:makerfaire,代码行数:92,代码来源:class-edit-entry-render.php

示例6: modify_edit_field_input

 /**
  *
  * Fill-in the saved values into the form inputs
  *
  * @param string $field_content Always empty. Returning not-empty overrides the input.
  * @param GF_Field $field
  * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
  * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
  * @param int $form_id Form ID
  *
  * @return mixed
  */
 function modify_edit_field_input($field_content = '', $field, $value, $lead_id = 0, $form_id)
 {
     $gv_field = GravityView_Fields::get_associated_field($field);
     // If the form has been submitted, then we don't need to pre-fill the values,
     // Except for fileupload type and when a field input is overridden- run always!!
     if ($this->is_edit_entry_submission() && !in_array($field->type, array('fileupload', 'post_image')) && false === ($gv_field && is_callable(array($gv_field, 'get_field_input'))) || !empty($field_content) || in_array($field->type, array('honeypot')) || GFCommon::is_product_field($field->type)) {
         return $field_content;
     }
     // Turn on Admin-style display for file upload fields only
     if ('fileupload' === $field->type) {
         $_GET['page'] = 'gf_entries';
     }
     // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
     $field->adminOnly = false;
     /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
     // add categories as choices for Post Category field
     if ('post_category' === $field->type) {
         $field = GFCommon::add_categories_as_choices($field, $value);
     }
     $field_value = $this->get_field_value($field);
     /**
      * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
      * @since 1.11
      * @param mixed $field_value field value used to populate the input
      * @param object $field Gravity Forms field object ( Class GF_Field )
      */
     $field_value = apply_filters('gravityview/edit_entry/field_value', $field_value, $field);
     /**
      * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
      * @since 1.17
      * @param mixed $field_value field value used to populate the input
      * @param GF_Field $field Gravity Forms field object
      */
     $field_value = apply_filters('gravityview/edit_entry/field_value_' . $field->type, $field_value, $field);
     // Prevent any PHP warnings, like undefined index
     ob_start();
     if ($gv_field && is_callable(array($gv_field, 'get_field_input'))) {
         /** @var GF_Field $gv_field */
         $return = $gv_field->get_field_input($this->form, $field_value, $this->entry, $field);
     } else {
         $return = $field->get_field_input($this->form, $field_value, $this->entry);
     }
     // If there was output, it's an error
     $warnings = ob_get_clean();
     if (!empty($warnings)) {
         do_action('gravityview_log_error', __METHOD__ . $warnings, $field_value);
     }
     /**
      * Unset hack $_GET['page'] = 'gf_entries'
      * We need the fileupload html field to render with the proper id
      *  ( <li id="field_80_16" ... > )
      */
     unset($_GET['page']);
     return $return;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:67,代码来源:class-edit-entry-render.php

示例7: failed_state_validation

 public static function failed_state_validation($form_id, $field, $value)
 {
     global $_gf_state;
     //if field can be populated dynamically, disable state validation
     if ($field->allowsPrepopulate) {
         return false;
     } else {
         if (!GFCommon::is_product_field($field->type && $field->type != 'donation')) {
             return false;
         } else {
             if (!in_array($field->inputType, array('singleshipping', 'singleproduct', 'hiddenproduct', 'checkbox', 'radio', 'select'))) {
                 return false;
             }
         }
     }
     if (!isset($_gf_state)) {
         $state = json_decode(base64_decode($_POST["state_{$form_id}"]), true);
         if (!$state || sizeof($state) != 2) {
             return true;
         }
         //making sure state wasn't tampered with by validating checksum
         $checksum = wp_hash(crc32($state[0]));
         if ($checksum !== $state[1]) {
             return true;
         }
         $_gf_state = json_decode($state[0], true);
     }
     if (!is_array($value)) {
         $value = array($field->id => $value);
     }
     foreach ($value as $key => $input_value) {
         $state = isset($_gf_state[$key]) ? $_gf_state[$key] : false;
         //converting price to a number for single product fields and single shipping fields
         if (in_array($field->inputType, array('singleproduct', 'hiddenproduct')) && $key == $field->id . '.2' || $field->inputType == 'singleshipping') {
             $input_value = GFCommon::to_number($input_value);
         }
         $hash = wp_hash($input_value);
         if (strlen($input_value) > 0 && $state !== false && (is_array($state) && !in_array($hash, $state) || !is_array($state) && $hash != $state)) {
             return true;
         }
     }
     return false;
 }
开发者ID:shahidbasheer,项目名称:gravityform,代码行数:43,代码来源:form_display.php

示例8: export_feed

 public static function export_feed($entry, $form, $feed)
 {
     $resubscribe = $feed["meta"]["resubscribe"] ? true : false;
     $email = $entry[$feed["meta"]["field_map"]["email"]];
     $name = "";
     if (!empty($feed["meta"]["field_map"]["fullname"])) {
         $name = self::get_name($entry, $feed["meta"]["field_map"]["fullname"]);
     }
     $merge_vars = array();
     foreach ($feed["meta"]["field_map"] as $var_key => $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         if (GFCommon::is_product_field($field["type"]) && rgar($field, "enablePrice")) {
             $ary = explode("|", $entry[$field_id]);
             $name = count($ary) > 0 ? $ary[0] : "";
             $merge_vars[] = array("Key" => $var_key, "Value" => $name);
         } else {
             if (RGFormsModel::get_input_type($field) == "checkbox") {
                 foreach ($field["inputs"] as $input) {
                     $index = (string) $input["id"];
                     if (!rgempty($index, $entry)) {
                         $merge_vars[] = array("Key" => $var_key, "Value" => $entry[$index]);
                     }
                 }
             } else {
                 if (!in_array($var_key, array('email', 'fullname'))) {
                     $merge_vars[] = array("Key" => $var_key, "Value" => $entry[$field_id]);
                 }
             }
         }
     }
     $subscriber = array('EmailAddress' => $email, 'Name' => $name, 'CustomFields' => $merge_vars, 'Resubscribe' => $resubscribe);
     $api = new CS_REST_Subscribers($feed["meta"]["contact_list_id"], self::get_api_key());
     $api->add($subscriber);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:34,代码来源:campaignmonitor.php

示例9: failed_state_validation

 public static function failed_state_validation($form_id, $field, $value)
 {
     global $_gf_state;
     if (!GFCommon::is_product_field($field["type"] && $field["type"] != "donation")) {
         return false;
     } else {
         if (!in_array($field["inputType"], array("singleshipping", "singleproduct", "checkbox", "radio", "select"))) {
             return false;
         }
     }
     if (!isset($_gf_state)) {
         $state = unserialize(base64_decode($_POST["state_{$form_id}"]));
         if (!$state || sizeof($state) != 2) {
             return true;
         }
         //making sure state wasn't tampered with by validating checksum
         $checksum = wp_hash(crc32($state[0]));
         if ($checksum != $state[1]) {
             return true;
         }
         $_gf_state = unserialize($state[0]);
     }
     if (!is_array($value)) {
         $value = array($field["id"] => $value);
     }
     foreach ($value as $key => $input_value) {
         $state = isset($_gf_state[$key]) ? $_gf_state[$key] : false;
         $hash = wp_hash($input_value);
         if (strlen($input_value) > 0 && $state !== false && (is_array($state) && !in_array($hash, $state) || !is_array($state) && $hash != $state)) {
             return true;
         }
     }
     return false;
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:34,代码来源:form_display.php

示例10: getmetaData

function getmetaData($entry_id)
{
    $return = '';
    $metaData = mf_get_form_meta('entry_id', $entry_id);
    foreach ($metaData as $data) {
        $entry = GFAPI::get_entry($data->lead_id);
        //check if entry-id is valid
        if (is_array($entry)) {
            //display entry data
            $formPull = GFAPI::get_form($data->form_id);
            $return .= '<h2>' . $formPull['title'] . '</h2>';
            $return .= '<table>';
            foreach ($formPull['fields'] as $formFields) {
                $gwreadonly_enable = isset($formFields['gwreadonly_enable']) ? $formFields['gwreadonly_enable'] : 0;
                //exclude page breaks and the entry fields used to verify the entry
                // and the display only fields from the additional forms
                if ($formFields['type'] != 'page' && $formFields['inputName'] != 'entry-id' && $formFields['inputName'] != 'contact-email' && $gwreadonly_enable != 1) {
                    $display_empty_fields = false;
                    switch (RGFormsModel::get_input_type($formFields)) {
                        case 'section':
                            if (!GFCommon::is_section_empty($formFields, $formPull, $entry) || $display_empty_fields) {
                                $count++;
                                $is_last = $count >= $field_count ? true : false;
                                ?>
                                        <tr>
                                                <td colspan="2" class="entry-view-section-break<?php 
                                echo $is_last ? ' lastrow' : '';
                                ?>
"><?php 
                                echo esc_html(GFCommon::get_label($formFields));
                                ?>
</td>
                                        </tr>
                                <?php 
                            }
                            break;
                        case 'captcha':
                        case 'html':
                        case 'password':
                        case 'page':
                            //ignore captcha, html, password, page field
                            break;
                        default:
                            //ignore product fields as they will be grouped together at the end of the grid
                            if (GFCommon::is_product_field($formFields->type)) {
                                $has_product_fields = true;
                                continue;
                            }
                            $value = RGFormsModel::get_lead_field_value($entry, $formFields);
                            $display_value = GFCommon::get_lead_field_display($formFields, $value, $entry['currency']);
                            $display_value = apply_filters('gform_entry_field_value', $display_value, $formFields, $entry, $formPull);
                            if ($display_empty_fields || !empty($display_value) || $display_value === '0') {
                                $display_value = empty($display_value) && $display_value !== '0' ? '&nbsp;' : $display_value;
                                $content = '
                                            <tr>
                                                <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($formFields)) . '</td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" class="entry-view-field-value">' . $display_value . '</td>
                                            </tr>';
                                $content = apply_filters('gform_field_content', $content, $formFields, $value, $entry['id'], $formPull['id']);
                                $return .= $content;
                            }
                            break;
                    }
                }
            }
            $return .= '</table>';
        }
    }
    return $return;
}
开发者ID:hansstam,项目名称:makerfaire,代码行数:72,代码来源:gf-entry-summary.php

示例11: lead_detail

    public static function lead_detail($Form, $lead, $allow_display_empty_fields = false, $inline = true, $options = array())
    {
        if (!class_exists('GFEntryList')) {
            require_once GFCommon::get_base_path() . "/entry_list.php";
        }
        global $current_user, $_gform_directory_approvedcolumn;
        get_currentuserinfo();
        $display_empty_fields = '';
        $allow_display_empty_fields = true;
        if ($allow_display_empty_fields) {
            $display_empty_fields = @rgget("gf_display_empty_fields", $_COOKIE);
        }
        if (empty($options)) {
            $options = self::directory_defaults();
        }
        // There is no edit link
        if (isset($_GET['edit']) || RGForms::post("action") === "update") {
            // Process editing leads
            $lead = self::edit_lead_detail($Form, $lead, $options);
            if (RGForms::post("action") !== "update") {
                return;
            }
        }
        extract($options);
        ?>
			<table cellspacing="0" class="widefat fixed entry-detail-view">
			<?php 
        $title = str_replace('%%formtitle%%', $Form["title"], str_replace('%%leadid%%', $lead['id'], $entrydetailtitle));
        if (!empty($title) && $inline) {
            ?>
				<thead>
					<tr>
						<th id="details" colspan="2" scope="col">
						<?php 
            $title = apply_filters('kws_gf_directory_detail_title', apply_filters('kws_gf_directory_detail_title_' . (int) $lead['id'], array($title, $lead), true), true);
            if (is_array($title)) {
                echo $title[0];
            } else {
                echo $title;
            }
            ?>
						</th>
					</tr>
				</thead>
				<?php 
        }
        ?>
				<tbody>
					<?php 
        $count = 0;
        $has_product_fields = false;
        $field_count = sizeof($Form["fields"]);
        $display_value = '';
        foreach ($Form["fields"] as $field) {
            // Don't show fields defined as hide in single.
            if (!empty($field['hideInSingle'])) {
                if (self::has_access("gravityforms_directory")) {
                    echo "\n\t\t\t\t\t\t\t\t\t" . '<!-- ' . sprintf(esc_html__('(Admin-only notice) Field #%d not shown: "Hide This Field in Single Entry View" was selected.', 'gravity-forms-addons'), $field['id']) . ' -->' . "\n\n";
                }
                continue;
            }
            $count++;
            $is_last = $count >= $field_count ? true : false;
            switch (RGFormsModel::get_input_type($field)) {
                case "section":
                    if (!GFCommon::is_section_empty($field, $Form, $lead) || $display_empty_fields) {
                        $count++;
                        $is_last = $count >= $field_count ? true : false;
                        ?>
	                                <tr>
	                                    <td colspan="2" class="entry-view-section-break<?php 
                        echo $is_last ? " lastrow" : "";
                        ?>
"><?php 
                        echo esc_html(GFCommon::get_label($field));
                        ?>
</td>
	                                </tr>
	                                <?php 
                    }
                    break;
                case "captcha":
                case "html":
                case "password":
                case "page":
                    //ignore captcha, html, password, page field
                    break;
                case "post_image":
                    $value = RGFormsModel::get_lead_field_value($lead, $field);
                    $valueArray = explode("|:|", $value);
                    @(list($url, $title, $caption, $description) = $valueArray);
                    if (!empty($url)) {
                        $value = $display_value = self::render_image_link($url, $lead, $options, $title, $caption, $description);
                    }
                    break;
                default:
                    //ignore product fields as they will be grouped together at the end of the grid
                    if (GFCommon::is_product_field($field["type"])) {
                        $has_product_fields = true;
                        continue;
//.........这里部分代码省略.........
开发者ID:healthcommcore,项目名称:osnap,代码行数:101,代码来源:gravity-forms-addons.php

示例12: get_field_value

 /**
  * Returns the value of the selected field.
  *
  * @param array $form The form object currently being processed.
  * @param array $entry The entry object currently being processed.
  * @param string $field_id The ID of the field being processed.
  *
  * @return array
  */
 public function get_field_value($form, $entry, $field_id)
 {
     $field_value = '';
     switch (strtolower($field_id)) {
         case 'form_title':
             $field_value = rgar($form, 'title');
             break;
         case 'date_created':
             $date_created = rgar($entry, strtolower($field_id));
             if (empty($date_created)) {
                 //the date created may not yet be populated if this function is called during the validation phase and the entry is not yet created
                 $field_value = gmdate('Y-m-d H:i:s');
             } else {
                 $field_value = $date_created;
             }
             break;
         case 'ip':
         case 'source_url':
             $field_value = rgar($entry, strtolower($field_id));
             break;
         default:
             $field = GFFormsModel::get_field($form, $field_id);
             if (is_object($field)) {
                 $is_integer = $field_id == intval($field_id);
                 $input_type = RGFormsModel::get_input_type($field);
                 if ($is_integer && $input_type == 'address') {
                     $field_value = $this->get_full_address($entry, $field_id);
                 } elseif ($is_integer && $input_type == 'name') {
                     $field_value = $this->get_full_name($entry, $field_id);
                 } elseif ($is_integer && $input_type == 'checkbox') {
                     foreach ($field->inputs as $input) {
                         $index = (string) $input['id'];
                         $field_value[] = $this->maybe_override_field_value(rgar($entry, $index), $form, $entry, $index);
                     }
                 } elseif ($input_type == 'multiselect') {
                     $value = $this->maybe_override_field_value(rgar($entry, $field_id), $form, $entry, $field_id);
                     if (!empty($value)) {
                         $field_value = explode(',', $value);
                     }
                 } elseif (GFCommon::is_product_field($field->type) && $field->enablePrice) {
                     $ary = explode('|', rgar($entry, $field_id));
                     $field_value = count($ary) > 0 ? $ary[0] : '';
                 } else {
                     if (is_callable(array('GF_Field', 'get_value_export'))) {
                         $field_value = $field->get_value_export($entry, $field_id);
                     } else {
                         $field_value = rgar($entry, $field_id);
                     }
                 }
                 if (!in_array($input_type, array('checkbox', 'multiselect'))) {
                     $field_value = $this->maybe_override_field_value($field_value, $form, $entry, $field_id);
                 }
             } else {
                 $field_value = $this->maybe_override_field_value(rgar($entry, $field_id), $form, $entry, $field_id);
             }
     }
     return $field_value;
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:67,代码来源:class-gf-campaignmonitor.php

示例13: get_form_fields

 /**
  * Return array of fields' id and label, for a given Form ID
  *
  * @access public
  * @param string|array $form_id (default: '') or $form object
  * @param bool $add_default_properties
  * @param bool $include_parent_field
  * @return array
  */
 public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true)
 {
     if (!is_array($form)) {
         $form = self::get_form($form);
     }
     $fields = array();
     $has_product_fields = false;
     $has_post_fields = false;
     if ($form) {
         foreach ($form['fields'] as $field) {
             if ($include_parent_field || empty($field['inputs'])) {
                 $fields["{$field->id}"] = array('label' => rgar($field, 'label'), 'parent' => null, 'type' => rgar($field, 'type'), 'adminLabel' => rgar($field, 'adminLabel'), 'adminOnly' => rgar($field, 'adminOnly'));
             }
             if ($add_default_properties && !empty($field->inputs)) {
                 foreach ($field->inputs as $input) {
                     /**
                      * @hack
                      * In case of email/email confirmation, the input for email has the same id as the parent field
                      */
                     if ('email' === $field->type && false === strpos($input['id'], '.')) {
                         continue;
                     }
                     $fields["{$input['id']}"] = array('label' => rgar($input, 'label'), 'customLabel' => rgar($input, 'customLabel'), 'parent' => $field, 'type' => rgar($field, 'type'), 'adminLabel' => rgar($field, 'adminLabel'), 'adminOnly' => rgar($field, 'adminOnly'));
                 }
             }
             if (GFCommon::is_product_field($field->type)) {
                 $has_product_fields = true;
             }
             if (GFCommon::is_post_field($field)) {
                 $has_post_fields = true;
             }
         }
     }
     /**
      * @since 1.7
      */
     if ($has_post_fields) {
         $fields['post_id'] = array('label' => __('Post ID', 'gravityview'), 'type' => 'post_id');
     }
     if ($has_product_fields) {
         $payment_fields = GravityView_Fields::get_all('pricing');
         foreach ($payment_fields as $payment_field) {
             if (isset($fields["{$payment_field->name}"])) {
                 continue;
             }
             $fields["{$payment_field->name}"] = array('label' => $payment_field->label, 'desc' => $payment_field->description, 'type' => $payment_field->name);
         }
     }
     /**
      * @filter `gravityview/common/get_form_fields` Modify the form fields shown in the Add Field field picker.
      * @since 1.17
      * @param array $fields Associative array of fields, with keys as field type, values an array with the following keys: (string) `label` (required), (string) `type` (required), `desc`, (string) `customLabel`, (GF_Field) `parent`, (string) `adminLabel`, (bool)`adminOnly`
      * @param array $form GF Form array
      * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs
      */
     $fields = apply_filters('gravityview/common/get_form_fields', $fields, $form, $include_parent_field);
     return $fields;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:67,代码来源:class-common.php

示例14: modify_edit_field_input

 /**
  *
  * Fill-in the saved values into the form inputs
  *
  * @param string $field_content Always empty.
  * @param GF_Field $field
  * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
  * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
  * @param int $form_id Form ID
  *
  * @return mixed
  */
 function modify_edit_field_input($field_content = '', $field, $value, $lead_id = 0, $form_id)
 {
     // If the form has been submitted, then we don't need to pre-fill the values,
     // Except for fileupload type - run always!!
     if ($this->is_edit_entry_submission() && 'fileupload' !== $field->type || GFCommon::is_product_field($field->type)) {
         return $field_content;
     }
     // Turn on Admin-style display for file upload fields only
     if ('fileupload' === $field->type) {
         $_GET['page'] = 'gf_entries';
     }
     // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
     $field->adminOnly = false;
     /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
     // add categories as choices for Post Category field
     if ('post_category' === $field->type) {
         $field = GFCommon::add_categories_as_choices($field, $value);
     }
     // We're dealing with multiple inputs (e.g. checkbox)
     if (isset($field->inputs) && is_array($field->inputs)) {
         $field_value = array();
         // only accept pre-populated values if the field doesn't have any choice selected.
         $allow_pre_populated = true;
         foreach ((array) $field->inputs as $input) {
             $input_id = strval($input['id']);
             if (!empty($this->entry[$input_id])) {
                 $allow_pre_populated = false;
                 $field_value[$input_id] = 'post_category' === $field->type ? GFCommon::format_post_category($this->entry[$input_id], true) : $this->entry[$input_id];
             }
         }
         if ($allow_pre_populated) {
             $field_value = $field->get_value_submission(array(), false);
         }
     } else {
         $id = intval($field->id);
         // get pre-populated value if exists
         $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value($field->inputName, array(), $field) : '';
         // saved field entry value (if empty, fallback to the pre-populated value, if exists)
         $field_value = !empty($this->entry[$id]) ? $this->entry[$id] : $pre_value;
         // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
         if ('post_category' === $field->type && !empty($field_value)) {
             $categories = array();
             foreach (explode(',', $field_value) as $cat_string) {
                 $categories[] = GFCommon::format_post_category($cat_string, true);
             }
             $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode('', $categories);
         }
     }
     // if value is empty get the default value if defined
     $field_value = $field->get_value_default_if_empty($field_value);
     // Prevent any PHP warnings, like undefined index
     ob_start();
     $return = $field->get_field_input($this->form, $field_value, $this->entry);
     // If there was output, it's an error
     $warnings = ob_get_clean();
     if (!empty($warnings)) {
         do_action('gravityview_log_error', __METHOD__ . $warnings);
     }
     /**
      * Unset hack $_GET['page'] = 'gf_entries'
      * We need the fileupload html field to render with the proper id
      *  ( <li id="field_80_16" ... > )
      */
     unset($_GET['page']);
     return $return;
 }
开发者ID:bobwol,项目名称:GravityView,代码行数:78,代码来源:class-edit-entry-render.php

示例15: failed_state_validation

 public static function failed_state_validation($form_id, $field, $value)
 {
     global $_gf_state;
     //if field can be populated dynamically, disable state validation
     if (rgar($field, "allowsPrepopulate")) {
         return false;
     } else {
         if (!GFCommon::is_product_field($field["type"] && $field["type"] != "donation")) {
             return false;
         } else {
             if (!in_array($field["inputType"], array("singleshipping", "singleproduct", "hiddenproduct", "checkbox", "radio", "select"))) {
                 return false;
             }
         }
     }
     if (!isset($_gf_state)) {
         $state = unserialize(base64_decode($_POST["state_{$form_id}"]));
         if (!$state || sizeof($state) != 2) {
             return true;
         }
         //making sure state wasn't tampered with by validating checksum
         $checksum = wp_hash(crc32($state[0]));
         if ($checksum != $state[1]) {
             return true;
         }
         $_gf_state = unserialize($state[0]);
     }
     if (!is_array($value)) {
         $value = array($field["id"] => $value);
     }
     foreach ($value as $key => $input_value) {
         $state = isset($_gf_state[$key]) ? $_gf_state[$key] : false;
         //converting price to a number for single product fields and single shipping fields
         if (in_array($field["inputType"], array("singleproduct", "hiddenproduct")) && $key == $field["id"] . ".2" || $field["inputType"] == "singleshipping") {
             $input_value = GFCommon::to_number($input_value);
         }
         $hash = wp_hash($input_value);
         if (strlen($input_value) > 0 && $state !== false && (is_array($state) && !in_array($hash, $state) || !is_array($state) && $hash != $state)) {
             return true;
         }
     }
     return false;
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:43,代码来源:form_display.php


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