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


PHP GFCommon::replace_variables方法代码示例

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


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

示例1: send_webhook

 function send_webhook()
 {
     $entry = $this->get_entry();
     $url = $this->url;
     $this->log_debug(__METHOD__ . '() - url before replacing variables: ' . $url);
     $url = GFCommon::replace_variables($url, $this->get_form(), $entry, true, false, false, 'text');
     $this->log_debug(__METHOD__ . '() - url after replacing variables: ' . $url);
     $method = strtoupper($this->method);
     $body = null;
     $headers = array();
     if (in_array($method, array('POST', 'PUT'))) {
         if ($this->format == 'json') {
             $headers = array('Content-type' => 'application/json');
             $body = json_encode($entry);
         } else {
             $headers = array();
             $body = $entry;
         }
     }
     $args = array('method' => $method, 'timeout' => 45, 'redirection' => 3, 'blocking' => true, 'headers' => $headers, 'body' => $body, 'cookies' => array());
     $args = apply_filters('gravityflow_webhook_args', $args, $entry, $this);
     $response = wp_remote_request($url, $args);
     $this->log_debug(__METHOD__ . '() - response: ' . print_r($response, true));
     if (is_wp_error($response)) {
         $step_status = 'error';
     } else {
         $step_status = 'success';
     }
     $note = esc_html__('Webhook sent. Url: ' . $url);
     $this->add_note($note, 0, 'webhook');
     do_action('gravityflow_post_webhook', $response, $args, $entry, $this);
     return $step_status;
 }
开发者ID:jakejackson1,项目名称:gravityflow,代码行数:33,代码来源:class-step-webhook.php

示例2: replace_variables

 /**
  * Check for merge tags before passing to Gravity Forms to improve speed.
  *
  * GF doesn't check for whether `{` exists before it starts diving in. They not only replace fields, they do `str_replace()` on things like ip address, which is a lot of work just to check if there's any hint of a replacement variable.
  *
  * We check for the basics first, which is more efficient.
  *
  * @since 1.8.4 - Moved to GravityView_Merge_Tags
  * @since 1.15.1 - Add support for $url_encode and $esc_html arguments
  *
  * @param  string      $text       Text to replace variables in
  * @param  array      $form        GF Form array
  * @param  array      $entry        GF Entry array
  * @param  bool       $url_encode   Pass return value through `url_encode()`
  * @param  bool       $esc_html     Pass return value through `esc_html()`
  * @return string                  Text with variables maybe replaced
  */
 public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true)
 {
     /**
      * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
      * Useful where you want to process variables yourself. We do this in the Math Extension.
      * @since 1.13
      * @param[in,out] boolean $do_replace_variables True: yes, replace variables for this text; False: do not replace variables.
      * @param[in] string $text       Text to replace variables in
      * @param[in]  array      $form        GF Form array
      * @param[in]  array      $entry        GF Entry array
      */
     $do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry);
     if (strpos($text, '{') === false || !$do_replace_variables) {
         return $text;
     }
     /**
      * Replace GravityView merge tags before going to Gravity Forms
      * This allows us to replace our tags first.
      * @since 1.15
      */
     $text = self::replace_gv_merge_tags($text, $form, $entry);
     // Check for fields - if they exist, we let Gravity Forms handle it.
     preg_match_all('/{[^{]*?:(\\d+(\\.\\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);
     if (empty($matches)) {
         // Check for form variables
         if (!preg_match('/\\{(all_fields(:(.*?))?|all_fields_display_empty|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|get:(.*?)|user:(.*?)|created_by:(.*?))\\}/ism', $text)) {
             return $text;
         }
     }
     return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html);
 }
开发者ID:kidaak,项目名称:GravityView,代码行数:48,代码来源:class-gravityview-merge-tags.php

示例3: replace_merge_tags

 function replace_merge_tags($post_content)
 {
     $entry = $this->get_entry();
     if (!$entry) {
         return $post_content;
     }
     $form = GFFormsModel::get_form_meta($entry['form_id']);
     $post_content = $this->replace_field_label_merge_tags($post_content, $form);
     $post_content = GFCommon::replace_variables($post_content, $form, $entry, false, false, false);
     return $post_content;
 }
开发者ID:KrissieV,项目名称:pioneer-and-southern,代码行数:11,代码来源:honeystreet-gfc.php

示例4: replace_variables

 /**
  * Check for merge tags before passing to Gravity Forms to improve speed.
  *
  * GF doesn't check for whether `{` exists before it starts diving in. They not only replace fields, they do `str_replace()` on things like ip address, which is a lot of work just to check if there's any hint of a replacement variable.
  *
  * We check for the basics first, which is more efficient.
  *
  * @since 1.8.4 - Moved to GravityView_Merge_Tags
  *
  * @param  string      $text       Text to replace variables in
  * @param  array      $form        GF Form array
  * @param  array      $entry        GF Entry array
  * @return string                  Text with variables maybe replaced
  */
 public static function replace_variables($text, $form, $entry)
 {
     if (strpos($text, '{') === false) {
         return $text;
     }
     // Check for fields - if they exist, we let Gravity Forms handle it.
     preg_match_all('/{[^{]*?:(\\d+(\\.\\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);
     if (empty($matches)) {
         // Check for form variables
         if (!preg_match('/\\{(all_fields(:(.*?))?|pricing_fields|form_title|entry_url|ip|post_id|admin_email|post_edit_url|form_id|entry_id|embed_url|date_mdy|date_dmy|embed_post:(.*?)|custom_field:(.*?)|user_agent|referer|gv:(.*?)|user:(.*?)|created_by:(.*?))\\}/ism', $text)) {
             return $text;
         }
     }
     return GFCommon::replace_variables($text, $form, $entry, false, false, false, "html");
 }
开发者ID:psdes,项目名称:GravityView,代码行数:29,代码来源:class-gravityview-merge-tags.php

示例5: test_gf_merge_tags

 /**
  * We want to make sure that GravityView doesn't mess with Texas
  * @since 1.15.1
  */
 function test_gf_merge_tags()
 {
     remove_all_filters('gform_pre_replace_merge_tags');
     remove_all_filters('gform_merge_tag_filter');
     global $post;
     $form = $this->factory->form->create_and_get();
     $post = $this->factory->post->create_and_get();
     $entry = $this->factory->entry->create_and_get(array('post_id' => $post->ID, 'form_id' => $form['id']));
     $tests = array('{form_title}' => $form['title'], '{entry_id}' => $entry['id'], '{entry_url}' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=gf_entries&view=entry&id=' . $form['id'] . '&lid=' . rgar($entry, 'id'), '{admin_email}' => get_bloginfo('admin_email'), '{post_id}' => $post->ID, '{embed_post:post_title}' => $post->post_title);
     foreach ($tests as $merge_tag => $expected) {
         $this->assertEquals($expected, GravityView_Merge_Tags::replace_variables($merge_tag, $form, $entry));
         $this->assertEquals(urlencode($expected), GravityView_Merge_Tags::replace_variables($merge_tag, $form, $entry, true));
         remove_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10);
         $this->assertEquals($expected, GFCommon::replace_variables($merge_tag, $form, $entry));
         $this->assertEquals(urlencode($expected), GFCommon::replace_variables($merge_tag, $form, $entry, true));
         add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7);
     }
     wp_reset_postdata();
 }
开发者ID:hansstam,项目名称:makerfaire,代码行数:23,代码来源:GravityView_Merge_Tags_Test.php

示例6: handle_confirmation

 public static function handle_confirmation($form, $lead, $ajax = false)
 {
     if ($form["confirmation"]["type"] == "message") {
         $default_anchor = self::has_pages($form) ? 1 : 0;
         $anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor)) ? "<a id='gf_{$form["id"]}' name='gf_{$form["id"]}' class='gform_anchor' ></a>" : "";
         $nl2br = rgar($form["confirmation"], "disableAutoformat") ? false : true;
         $confirmation = empty($form["confirmation"]["message"]) ? "{$anchor} " : "{$anchor}<div id='gforms_confirmation_message' class='gform_confirmation_message_{$form["id"]}'>" . GFCommon::replace_variables($form["confirmation"]["message"], $form, $lead, false, true, $nl2br) . "</div>";
     } else {
         if (!empty($form["confirmation"]["pageId"])) {
             $url = get_permalink($form["confirmation"]["pageId"]);
         } else {
             $url = GFCommon::replace_variables(trim($form["confirmation"]["url"]), $form, $lead, false, true);
             $url_info = parse_url($url);
             $query_string = $url_info["query"];
             $dynamic_query = GFCommon::replace_variables(trim($form["confirmation"]["queryString"]), $form, $lead, true);
             $query_string .= empty($url_info["query"]) || empty($dynamic_query) ? $dynamic_query : "&" . $dynamic_query;
             if (!empty($url_info["fragment"])) {
                 $query_string .= "#" . $url_info["fragment"];
             }
             $url = $url_info["scheme"] . "://" . $url_info["host"];
             if (!empty($url_info["port"])) {
                 $url .= ":{$url_info["port"]}";
             }
             $url .= rgar($url_info, "path");
             if (!empty($query_string)) {
                 $url .= "?{$query_string}";
             }
         }
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($url, $ajax);
         } else {
             $confirmation = array("redirect" => $url);
         }
     }
     $confirmation = apply_filters("gform_confirmation_{$form["id"]}", apply_filters("gform_confirmation", $confirmation, $form, $lead, $ajax), $form, $lead, $ajax);
     if (!is_array($confirmation)) {
         $confirmation = GFCommon::gform_do_shortcode($confirmation);
         //enabling shortcodes
     } else {
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($confirmation["redirect"], $ajax);
             //redirecting via client side
         }
     }
     return $confirmation;
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:48,代码来源:form_display.php

示例7: handle_save_email_confirmation

 public static function handle_save_email_confirmation($form, $ajax)
 {
     $resume_email = $_POST['gform_resume_email'];
     if (!GFCommon::is_valid_email($resume_email)) {
         GFCommon::log_debug('GFFormDisplay::handle_save_email_confirmation(): Invalid email address: ' . $resume_email);
         return new WP_Error('invalid_email');
     }
     $resume_token = $_POST['gform_resume_token'];
     $submission_details = GFFormsModel::get_incomplete_submission_values($resume_token);
     $submission_json = $submission_details['submission'];
     $submission = json_decode($submission_json, true);
     $entry = $submission['partial_entry'];
     $form = self::update_confirmation($form, $entry, 'form_save_email_sent');
     $confirmation = '<div class="form_saved_message_sent"><span>' . rgar($form['confirmation'], 'message') . '</span></div>';
     $nl2br = rgar($form['confirmation'], 'disableAutoformat') ? false : true;
     $save_email_confirmation = self::replace_save_variables($confirmation, $form, $resume_token, $resume_email);
     $save_email_confirmation = GFCommon::replace_variables($save_email_confirmation, $form, $entry, false, true, $nl2br);
     $save_email_confirmation = GFCommon::gform_do_shortcode($save_email_confirmation);
     $form_id = absint($form['id']);
     $has_pages = self::has_pages($form);
     $default_anchor = $has_pages || $ajax ? true : false;
     $use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
     if ($use_anchor !== false) {
         $save_email_confirmation = "<a id='gf_{$form_id}' class='gform_anchor' ></a>" . $save_email_confirmation;
     }
     if ($ajax) {
         $save_email_confirmation = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $save_email_confirmation . '</body></html>';
     }
     GFCommon::log_debug('GFFormDisplay::handle_save_email_confirmation(): Confirmation => ' . print_r($save_email_confirmation, true));
     return $save_email_confirmation;
 }
开发者ID:timk85,项目名称:DIT,代码行数:31,代码来源:form_display.php

示例8: create_post

 public static function create_post($form, &$lead)
 {
     $has_post_field = false;
     foreach ($form["fields"] as $field) {
         $is_hidden = self::is_field_hidden($form, $field, array(), $lead);
         if (!$is_hidden && in_array($field["type"], array("post_category", "post_title", "post_content", "post_excerpt", "post_tags", "post_custom_field", "post_image"))) {
             $has_post_field = true;
             break;
         }
     }
     //if this form does not have any post fields, don't create a post
     if (!$has_post_field) {
         return $lead;
     }
     //processing post fields
     $post_data = self::get_post_fields($form, $lead);
     //allowing users to change post fields before post gets created
     $post_data = apply_filters("gform_post_data_{$form["id"]}", apply_filters("gform_post_data", $post_data, $form, $lead), $form, $lead);
     //adding default title if none of the required post fields are in the form (will make sure wp_insert_post() inserts the post)
     if (empty($post_data["post_title"]) && empty($post_data["post_content"]) && empty($post_data["post_excerpt"])) {
         $post_data["post_title"] = self::get_default_post_title();
     }
     //inserting post
     if (GFCommon::is_bp_active()) {
         //disable buddy press action so save_post is not called because the post data is not yet complete at this point
         remove_action("save_post", "bp_blogs_record_post");
     }
     $post_id = wp_insert_post($post_data);
     //adding form id and entry id hidden custom fields
     add_post_meta($post_id, "_gform-form-id", $form["id"]);
     add_post_meta($post_id, "_gform-entry-id", $lead["id"]);
     //creating post images
     $post_images = array();
     foreach ($post_data["images"] as $image) {
         $image_meta = array("post_excerpt" => $image["caption"], "post_content" => $image["description"]);
         //adding title only if it is not empty. It will default to the file name if it is not in the array
         if (!empty($image["title"])) {
             $image_meta["post_title"] = $image["title"];
         }
         if (!empty($image["url"])) {
             $media_id = self::media_handle_upload($image["url"], $post_id, $image_meta);
             if ($media_id) {
                 //save media id for post body/title template variable replacement (below)
                 $post_images[$image["field_id"]] = $media_id;
                 $lead[$image["field_id"]] .= "|:|{$media_id}";
                 // set featured image
                 $field = RGFormsModel::get_field($form, $image["field_id"]);
                 if (rgar($field, 'postFeaturedImage')) {
                     set_post_thumbnail($post_id, $media_id);
                 }
             }
         }
     }
     //adding custom fields
     foreach ($post_data["post_custom_fields"] as $meta_name => $meta_value) {
         if (!is_array($meta_value)) {
             $meta_value = array($meta_value);
         }
         $meta_index = 0;
         foreach ($meta_value as $value) {
             $custom_field = self::get_custom_field($form, $meta_name, $meta_index);
             //replacing template variables if template is enabled
             if ($custom_field && rgget("customFieldTemplateEnabled", $custom_field)) {
                 //replacing post image variables
                 $value = GFCommon::replace_variables_post_image($custom_field["customFieldTemplate"], $post_images, $lead);
                 //replacing all other variables
                 $value = GFCommon::replace_variables($value, $form, $lead, false, false, false);
                 // replace conditional shortcodes
                 $value = do_shortcode($value);
             }
             switch (RGFormsModel::get_input_type($custom_field)) {
                 case "list":
                     $value = maybe_unserialize($value);
                     if (is_array($value)) {
                         foreach ($value as $item) {
                             if (is_array($item)) {
                                 $item = implode("|", $item);
                             }
                             if (!rgblank($item)) {
                                 add_post_meta($post_id, $meta_name, $item);
                             }
                         }
                     }
                     break;
                 case "multiselect":
                 case "checkbox":
                     $value = explode(",", $value);
                     if (is_array($value)) {
                         foreach ($value as $item) {
                             if (!rgblank($item)) {
                                 add_post_meta($post_id, $meta_name, $item);
                             }
                         }
                     }
                     break;
                 case "date":
                     $value = GFCommon::date_display($value, rgar($custom_field, "dateFormat"));
                     if (!rgblank($value)) {
                         add_post_meta($post_id, $meta_name, $value);
                     }
//.........这里部分代码省略.........
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:101,代码来源:forms_model.php

示例9: process_feed

 /**
  * Process feed.
  * 
  * @access public
  * @param array $feed
  * @param array $entry
  * @param array $form
  * @return void
  */
 public function process_feed($feed, $entry, $form)
 {
     $this->log_debug(__METHOD__ . '(): Processing feed.');
     /* If HipChat instance is not initialized, exit. */
     if (!$this->initialize_api()) {
         $this->add_feed_error(esc_html__('Feed was not processed because API was not initialized.', 'gravityformsslack'), $feed, $entry, $form);
         return;
     }
     /* Prepare notification array. */
     $notification = array('color' => $feed['meta']['color'], 'from' => 'Gravity Forms', 'message' => $feed['meta']['message'], 'notify' => $feed['meta']['notify'], 'room_id' => $feed['meta']['room']);
     /* Replace merge tags on notification message. */
     $notification['message'] = GFCommon::replace_variables($notification['message'], $form, $entry);
     /* Strip unallowed tags */
     $notification['message'] = strip_tags($notification['message'], '<a><b><i><strong><em><br><img><pre><code><lists><tables>');
     /* If message is empty, exit. */
     if (rgblank($notification['message'])) {
         $this->add_feed_error(esc_html__('Notification was not posted to room because message was empty.', 'gravityformshipchat'), $feed, $entry, $form);
         return;
     }
     /* If message is too long, cut it off at 10,000 characters. */
     if (strlen($notification['message']) > 10000) {
         $notification['message'] = substr($notification['message'], 0, 10000);
     }
     /* Post notification to room. */
     $this->log_debug(__METHOD__ . '(): Posting notification: ' . print_r($notification, true));
     $notify_room = $this->api->notify_room($notification);
     if (isset($notify_room['status']) && $notify_room['status'] == 'sent') {
         $this->log_debug(__METHOD__ . '(): Notification was posted to room.');
     } else {
         $this->add_feed_error(esc_html__('Notification was not posted to room.', 'gravityformshipchat'), $feed, $entry, $form);
     }
 }
开发者ID:wp-premium,项目名称:gravityformshipchat,代码行数:41,代码来源:class-gf-hipchat.php

示例10: handle_confirmation

 public static function handle_confirmation($form, $lead, $ajax = false)
 {
     //run the function to populate the legacy confirmation format to be safe
     $form = self::update_confirmation($form, $lead);
     if ($form["confirmation"]["type"] == "message") {
         $default_anchor = self::has_pages($form) ? 1 : 0;
         $anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor)) ? "<a id='gf_{$form["id"]}' name='gf_{$form["id"]}' class='gform_anchor' ></a>" : "";
         $nl2br = rgar($form["confirmation"], "disableAutoformat") ? false : true;
         $cssClass = rgar($form, "cssClass");
         if (function_exists('qtranxf_getLanguage') && !empty($form["confirmation"]["message"])) {
             $form["confirmation"]["message"] = apply_filters('the_title', $form["confirmation"]["message"]);
         }
         //$confirmation = empty($form["confirmation"]["message"]) ? "{$anchor} " : "{$anchor}<div id='gform_confirmation_wrapper_{$form["id"]}' class='gform_confirmation_wrapper {$cssClass}'><div id='gforms_confirmation_message' class='gform_confirmation_message_{$form["id"]}'>" . GFCommon::replace_variables($form["confirmation"]["message"], $form, $lead, false, true, $nl2br) . "</div></div>";
         $confirmation = empty($form["confirmation"]["message"]) ? "{$anchor} " : "{$anchor}<div id='gform_confirmation_wrapper_{$form["id"]}' class='validation_error alert alert-danger alert-dismissible fade in gform_confirmation_wrapper {$cssClass}'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button><div id='gforms_confirmation_message' class='gform_confirmation_message_{$form["id"]}'>" . GFCommon::replace_variables($form["confirmation"]["message"], $form, $lead, false, true, $nl2br) . "<a onclick='document.location.reload(true)'> Please, click to proceed</a></div></div>";
     } else {
         if (!empty($form["confirmation"]["pageId"])) {
             $url = get_permalink($form["confirmation"]["pageId"]);
         } else {
             $url = GFCommon::replace_variables(trim($form["confirmation"]["url"]), $form, $lead, false, true);
             $url_info = parse_url($url);
             $query_string = $url_info["query"];
             $dynamic_query = GFCommon::replace_variables(trim($form["confirmation"]["queryString"]), $form, $lead, true);
             $query_string .= empty($url_info["query"]) || empty($dynamic_query) ? $dynamic_query : "&" . $dynamic_query;
             if (!empty($url_info["fragment"])) {
                 $query_string .= "#" . $url_info["fragment"];
             }
             $url = $url_info["scheme"] . "://" . $url_info["host"];
             if (!empty($url_info["port"])) {
                 $url .= ":{$url_info["port"]}";
             }
             $url .= rgar($url_info, "path");
             if (!empty($query_string)) {
                 $url .= "?{$query_string}";
             }
         }
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($url, $ajax);
         } else {
             $confirmation = array("redirect" => $url);
         }
     }
     $confirmation = apply_filters("gform_confirmation_{$form["id"]}", apply_filters("gform_confirmation", $confirmation, $form, $lead, $ajax), $form, $lead, $ajax);
     if (!is_array($confirmation)) {
         $confirmation = GFCommon::gform_do_shortcode($confirmation);
         //enabling shortcodes
     } else {
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($confirmation["redirect"], $ajax);
             //redirecting via client side
         }
     }
     return $confirmation;
 }
开发者ID:jonnSmith,项目名称:btforms,代码行数:55,代码来源:form_display.php

示例11: send_admin_notification

 public static function send_admin_notification($form, $lead)
 {
     $form_id = $form["id"];
     //handling admin notification email
     $subject = GFCommon::replace_variables($form["notification"]["subject"], $form, $lead, false, false);
     $message = GFCommon::replace_variables($form["notification"]["message"], $form, $lead, false, false, !$form["notification"]["disableAutoformat"]);
     $message = do_shortcode($message);
     $from = empty($form["notification"]["fromField"]) ? $form["notification"]["from"] : $lead[$form["notification"]["fromField"]];
     if (empty($form["notification"]["fromNameField"])) {
         $from_name = $form["notification"]["fromName"];
     } else {
         $field = RGFormsModel::get_field($form, $form["notification"]["fromNameField"]);
         $value = RGFormsModel::get_lead_field_value($lead, $field);
         $from_name = GFCommon::get_lead_field_display($field, $value);
     }
     $replyTo = empty($form["notification"]["replyToField"]) ? $form["notification"]["replyTo"] : $lead[$form["notification"]["replyToField"]];
     if (empty($form["notification"]["routing"])) {
         $email_to = $form["notification"]["to"];
     } else {
         $email_to = array();
         foreach ($form["notification"]["routing"] as $routing) {
             $source_field = RGFormsModel::get_field($form, $routing["fieldId"]);
             $field_value = RGFormsModel::get_field_value($source_field, array());
             $is_value_match = is_array($field_value) ? in_array($routing["value"], $field_value) : $field_value == $routing["value"];
             if ($routing["operator"] == "is" && $is_value_match || $routing["operator"] == "isnot" && !$is_value_match) {
                 $email_to[] = $routing["email"];
             }
         }
         $email_to = join(",", $email_to);
     }
     //Running through variable replacement
     $email_to = GFCommon::replace_variables($email_to, $form, $lead, false, false);
     $from = GFCommon::replace_variables($from, $form, $lead, false, false);
     $bcc = GFCommon::replace_variables($form["notification"]["bcc"], $form, $lead, false, false);
     $reply_to = GFCommon::replace_variables($replyTo, $form, $lead, false, false);
     $from_name = GFCommon::replace_variables($from_name, $form, $lead, false, false);
     //Filters the admin notification email to address. Allows users to change email address before notification is sent
     $to = apply_filters("gform_notification_email_{$form_id}", apply_filters("gform_notification_email", $email_to, $lead), $lead);
     self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name);
 }
开发者ID:novuscory,项目名称:ACH,代码行数:40,代码来源:common.php

示例12: lead_detail_page


//.........这里部分代码省略.........
            _e("Add Note", "gravityforms");
            ?>
" class="button" style="width:60px;" onclick="jQuery('#action').val('add_quick_note');"/>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                       <!-- end side notes -->
                   <?php 
        }
        ?>

                   <!-- begin print button -->
                   <div class="detail-view-print">
                       <a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo GFCommon::get_base_url();
        ?>
/print-entry.php?fid=<?php 
        echo $form['id'];
        ?>
&lid=<?php 
        echo $lead['id'];
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button">Print</a>
                       <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                           <input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes"/>
                           <label for="print_notes">include notes</label>
                       <?php 
        }
        ?>
                   </div>
                   <!-- end print button -->

                </div>

                <div id="post-body" class="has-sidebar">
                    <div id="post-body-content" class="has-sidebar-content">
                        <?php 
        if ($mode == "view") {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        ?>

                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                            <div id="namediv" class="stuffbox">
                                <h3>
                                    <label for="name"><?php 
            _e("Notes", "gravityforms");
            ?>
</label>
                                </h3>

                                <form method="post">
                                    <?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
                                    <div class="inside">
                                        <?php 
            $notes = RGFormsModel::get_lead_notes($lead["id"]);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field["id"]])) {
                    $emails[] = $lead[$email_field["id"]];
                }
            }
            //displaying notes grid
            $subject = !empty($form["autoResponder"]["subject"]) ? "RE: " . GFCommon::replace_variables($form["autoResponder"]["subject"], $form, $lead) : "";
            self::notes_grid($notes, true, $emails, $subject);
            ?>
                                    </div>
                                </form>
                            </div>
                        <?php 
        }
        ?>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <?php 
        if (rgpost("action") == "update") {
            ?>
            <div class="updated fade" style="padding:6px;">
                <?php 
            _e("Entry Updated.", "gravityforms");
            ?>
            </div>
            <?php 
        }
    }
开发者ID:hypenotic,项目名称:slowfood,代码行数:101,代码来源:entry_detail.php

示例13: update_contact

 /**
  * Update contact.
  * 
  * @access public
  * @param array $contact
  * @param array $feed
  * @param array $entry
  * @param array $form
  * @return array $contact
  */
 public function update_contact($contact, $feed, $entry, $form)
 {
     $this->log_debug(__METHOD__ . '(): Updating existing contact.');
     /* Setup mapped fields array. */
     $contact_standard_fields = $this->get_field_map_fields($feed, 'contactStandardFields');
     $contact_custom_fields = $this->get_dynamic_field_map_fields($feed, 'contactCustomFields');
     /* Setup base fields. */
     $first_name = $this->get_field_value($form, $entry, $contact_standard_fields['first_name']);
     $last_name = $this->get_field_value($form, $entry, $contact_standard_fields['last_name']);
     $default_email = $this->get_field_value($form, $entry, $contact_standard_fields['email_address']);
     /* If the name is empty, exit. */
     if (rgblank($first_name) || rgblank($last_name)) {
         $this->add_feed_error(esc_html__('Contact could not be created as first and/or last name were not provided.', 'gravityformsagilecrm'), $feed, $entry, $form);
         return null;
     }
     /* If the email address is empty, exit. */
     if (GFCommon::is_invalid_or_empty_email($default_email)) {
         $this->add_feed_error(esc_html__('Contact could not be created as email address was not provided.', 'gravityformsagilecrm'), $feed, $entry, $form);
         return null;
     }
     /* Clear out unneeded data. */
     foreach ($contact as $key => $value) {
         if (!in_array($key, array('tags', 'properties', 'id', 'type'))) {
             unset($contact[$key]);
         }
     }
     /* If we're replacing all data, clear out the properties and add the base properties. */
     if (rgars($feed, 'meta/updateContactAction') == 'replace') {
         $contact['tags'] = array();
         $contact['properties'] = array(array('type' => 'SYSTEM', 'name' => 'first_name', 'value' => $first_name), array('type' => 'SYSTEM', 'name' => 'last_name', 'value' => $last_name), array('type' => 'SYSTEM', 'name' => 'email', 'value' => $default_email));
     }
     /* Add custom field data. */
     foreach ($contact_custom_fields as $field_key => $field_id) {
         /* Get the field value. */
         $this->custom_field_key = $field_key;
         $field_value = $this->get_field_value($form, $entry, $field_id);
         /* If the field value is empty, skip this field. */
         if (rgblank($field_value)) {
             continue;
         }
         $contact = $this->add_contact_property($contact, $field_key, $field_value, rgars($feed, 'meta/updateContactAction') == 'replace');
     }
     /* Prepare tags. */
     if (rgars($feed, 'meta/contactTags')) {
         $tags = GFCommon::replace_variables($feed['meta']['contactTags'], $form, $entry, false, false, false, 'text');
         $tags = array_map('trim', explode(',', $tags));
         $tags = array_merge($contact['tags'], $tags);
         $contact['tags'] = gf_apply_filters('gform_agilecrm_tags', $form['id'], $tags, $feed, $entry, $form);
     }
     $this->log_debug(__METHOD__ . '(): Updating contact: ' . print_r($contact, true));
     try {
         /* Update contact. */
         $this->api->update_contact($contact);
         /* Save contact ID to entry. */
         gform_update_meta($entry['id'], 'agilecrm_contact_id', $contact['id']);
         /* Log that contact was updated. */
         $this->log_debug(__METHOD__ . '(): Contact #' . $contact['id'] . ' updated.');
     } catch (Exception $e) {
         $this->add_feed_error(sprintf(esc_html__('Contact could not be updated. %s', 'gravityformsagilecrm'), $e->getMessage()), $feed, $entry, $form);
         return null;
     }
     return $contact;
 }
开发者ID:wp-premium,项目名称:gravityformsagilecrm,代码行数:73,代码来源:class-gf-agilecrm.php

示例14: process_feed

 /**
  * Process feed.
  * 
  * @access public
  * @param array $feed
  * @param array $entry
  * @param array $form
  * @return void
  */
 public function process_feed($feed, $entry, $form)
 {
     /* If Campfire instance is not initialized, exit. */
     if (!$this->initialize_api()) {
         $this->add_feed_error(esc_html__('Message was not posted to room because API was not initialized.', 'gravityformscampfire'), $feed, $entry, $form);
         return;
     }
     /* Prepare message. */
     $message = array('type' => 'TextMessage', 'body' => gf_apply_filters('gform_campfire_message', $form['id'], rgars($feed, 'meta/message'), $feed, $entry, $form));
     /* Replace merge tags in message. */
     $message['body'] = GFCommon::replace_variables($message['body'], $form, $entry);
     /* If message is empty, exit. */
     if (rgblank($message['body'])) {
         $this->add_feed_error(esc_html__('Message was not posted to room because it was empty.', 'gravityformscampfire'), $feed, $entry, $form);
         return;
     }
     try {
         /* Post message. */
         $message = $this->api->create_message(rgars($feed, 'meta/room'), $message);
         /* Log that message was posted. */
         $this->log_debug(__METHOD__ . '(): Message #' . $message['id'] . ' was posted to room #' . $message['room_id'] . '.');
     } catch (Exception $e) {
         /* Log that message was not posted. */
         $this->add_feed_error(sprintf(esc_html__('Message was not posted to room: %s', 'gravityformscampfire'), $e->getMessage()), $feed, $entry, $form);
         return false;
     }
     if (rgars($feed, 'meta/highlight') == '1') {
         try {
             /* Highlight message. */
             $this->api->highlight_message($message['id']);
             /* Log that message was posted. */
             $this->log_debug(__METHOD__ . '(): Message #' . $message['id'] . ' was highlighted.');
         } catch (Exception $e) {
             /* Log that message was not posted. */
             $this->add_feed_error(sprintf(esc_html__('Message was not highlighted: %s', 'gravityformscampfire'), $e->getMessage()), $feed, $entry, $form);
             return false;
         }
     }
 }
开发者ID:wp-premium,项目名称:gravityformscampfire,代码行数:48,代码来源:class-gf-campfire.php

示例15: handle_confirmation

 public static function handle_confirmation($form, $lead, $ajax = false)
 {
     GFCommon::log_debug("Sending confirmation");
     //run the function to populate the legacy confirmation format to be safe
     $form = self::update_confirmation($form, $lead);
     if ($form["confirmation"]["type"] == "message") {
         $default_anchor = self::has_pages($form) ? 1 : 0;
         $anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor)) ? "<a id='gf_{$form["id"]}' name='gf_{$form["id"]}' class='gform_anchor' ></a>" : "";
         $nl2br = rgar($form["confirmation"], "disableAutoformat") ? false : true;
         $cssClass = rgar($form, "cssClass");
         $confirmation = empty($form["confirmation"]["message"]) ? "{$anchor} " : "{$anchor}<div id='gform_confirmation_wrapper_{$form["id"]}' class='gform_confirmation_wrapper {$cssClass}'><div id='gform_confirmation_message_{$form["id"]}' class='gform_confirmation_message_{$form["id"]} gform_confirmation_message'>" . GFCommon::replace_variables($form["confirmation"]["message"], $form, $lead, false, true, $nl2br) . "</div></div>";
     } else {
         if (!empty($form['confirmation']['pageId'])) {
             $url = get_permalink($form['confirmation']['pageId']);
         } else {
             $url = GFCommon::replace_variables(trim($form['confirmation']['url']), $form, $lead, false, true, true, 'text');
         }
         $url_info = parse_url($url);
         $query_string = rgar($url_info, 'query');
         $dynamic_query = GFCommon::replace_variables(trim($form['confirmation']['queryString']), $form, $lead, true, false, false, 'text');
         $query_string .= rgempty('query', $url_info) || empty($dynamic_query) ? $dynamic_query : '&' . $dynamic_query;
         if (!empty($url_info['fragment'])) {
             $query_string .= '#' . rgar($url_info, 'fragment');
         }
         $url = $url_info['scheme'] . '://' . rgar($url_info, 'host');
         if (!empty($url_info['port'])) {
             $url .= ':' . rgar($url_info, 'port');
         }
         $url .= rgar($url_info, 'path');
         if (!empty($query_string)) {
             $url .= "?{$query_string}";
         }
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($url, $ajax);
         } else {
             $confirmation = array('redirect' => $url);
         }
     }
     $confirmation = apply_filters("gform_confirmation_{$form["id"]}", apply_filters("gform_confirmation", $confirmation, $form, $lead, $ajax), $form, $lead, $ajax);
     if (!is_array($confirmation)) {
         $confirmation = GFCommon::gform_do_shortcode($confirmation);
         //enabling shortcodes
     } else {
         if (headers_sent() || $ajax) {
             //Perform client side redirect for AJAX forms, of if headers have already been sent
             $confirmation = self::get_js_redirect_confirmation($confirmation["redirect"], $ajax);
             //redirecting via client side
         }
     }
     GFCommon::log_debug("Confirmation: " . print_r($confirmation, true));
     return $confirmation;
 }
开发者ID:nickyshannon,项目名称:miriam,代码行数:53,代码来源:form_display.php


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