本文整理汇总了PHP中GFCommon::replace_variables_prepopulate方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::replace_variables_prepopulate方法的具体用法?PHP GFCommon::replace_variables_prepopulate怎么用?PHP GFCommon::replace_variables_prepopulate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::replace_variables_prepopulate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$content = $is_entry_detail || $is_form_editor ? "<div class='gf-html-container'><span class='gf_blockheader'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-code fa-lg'></i> " . __('HTML Content', 'gravityforms') . '</span><span>' . __('This is a content placeholder. HTML content is not displayed in the form admin. Preview this form to view the content.', 'gravityforms') . '</span></div>' : $this->content;
$content = GFCommon::replace_variables_prepopulate($content);
// adding support for merge tags
$content = do_shortcode($content);
// adding support for shortcodes
return $content;
}
示例2: get_default_value
public static function get_default_value($field, $input_id)
{
if (!is_array($field->choices)) {
if (is_array($field->inputs)) {
$input = RGFormsModel::get_input($field, $input_id);
return rgar($input, 'defaultValue');
} else {
return IS_ADMIN ? $field->defaultValue : GFCommon::replace_variables_prepopulate($field->defaultValue);
}
} else {
if ($field->type == 'checkbox') {
for ($i = 0, $count = sizeof($field->inputs); $i < $count; $i++) {
$input = $field->inputs[$i];
$choice = $field->choices[$i];
if ($input['id'] == $input_id && rgar($choice, 'isSelected')) {
return $choice['value'];
}
}
return '';
} else {
foreach ($field->choices as $choice) {
if (rgar($choice, 'isSelected') || $field->type == 'post_category') {
return $choice['value'];
}
}
return '';
}
}
}
示例3: default_if_empty
private static function default_if_empty($field, $value)
{
if (!GFCommon::is_empty_array($value)) {
return $value;
}
if (IS_ADMIN) {
$value = rgget("defaultValue", $field);
} else {
$value = rgar($field, "defaultValue");
if (!is_array($value)) {
$value = GFCommon::replace_variables_prepopulate(rgget("defaultValue", $field));
}
}
return $value;
}
示例4: get_value_default
/**
* Retrieve the field default value.
*
* @return array|string
*/
public function get_value_default()
{
if (is_array($this->inputs)) {
$value = array();
foreach ($this->inputs as $input) {
$value[strval($input['id'])] = $this->is_form_editor() ? rgar($input, 'defaultValue') : GFCommon::replace_variables_prepopulate(rgar($input, 'defaultValue'));
}
} else {
$value = $this->is_form_editor() ? $this->defaultValue : GFCommon::replace_variables_prepopulate($this->defaultValue);
}
return $value;
}
示例5: get_default_value
public static function get_default_value($field, $input_id)
{
if (!is_array(rgar($field, "choices"))) {
if (is_array(rgar($field, "inputs"))) {
$input = RGFormsModel::get_input($field, $input_id);
return rgar($input, "defaultValue");
} else {
return IS_ADMIN ? $field["defaultValue"] : GFCommon::replace_variables_prepopulate($field["defaultValue"]);
}
} else {
if ($field["type"] == "checkbox") {
for ($i = 0, $count = sizeof($field["inputs"]); $i < $count; $i++) {
$input = $field["inputs"][$i];
$choice = $field["choices"][$i];
if ($input["id"] == $input_id && $choice["isSelected"]) {
return $choice["value"];
}
}
return "";
} else {
foreach ($field["choices"] as $choice) {
if ($choice["isSelected"] || $field["type"] == "post_category") {
return $choice["value"];
}
}
return "";
}
}
}
示例6: get_value_default
public function get_value_default()
{
return $this->is_form_editor() ? $this->defaultValue : GFCommon::replace_variables_prepopulate($this->defaultValue);
}
示例7: get_field_input
//.........这里部分代码省略.........
return $post_link;
}
$html_input_type = RGFormsModel::is_html5_enabled() ? "email" : "text";
if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
$single_style = rgget("emailConfirmEnabled", $field) ? "style='display:none;'" : "";
$confirm_style = rgget("emailConfirmEnabled", $field) ? "" : "style='display:none;'";
return "<div class='ginput_container ginput_single_email' {$single_style}><input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' /></div><div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' /><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' /><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
} else {
$logic_event = self::get_logic_event($field, "keyup");
if (rgget("emailConfirmEnabled", $field) && RG_CURRENT_VIEW != "entry") {
$first_tabindex = self::get_tabindex();
$last_tabindex = self::get_tabindex();
return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$logic_event} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . esc_attr(rgpost("input_" . $id . "_2")) . "' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
} else {
$tabindex = self::get_tabindex();
return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} {$logic_event} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
}
}
break;
case "honeypot":
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : "";
return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
break;
case "hidden":
if (!empty($post_link)) {
return $post_link;
}
$field_type = IS_ADMIN ? "text" : "hidden";
$class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
break;
case "html":
$content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
$content = GFCommon::replace_variables_prepopulate($content);
//adding support for merge tags
$content = do_shortcode($content);
//adding support for shortcodes
return $content;
break;
case "adminonly_hidden":
if (!is_array($field["inputs"])) {
return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
}
$fields = "";
foreach ($field["inputs"] as $input) {
$fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr(rgar($value, $input["id"])));
}
return $fields;
break;
case "number":
if (!empty($post_link)) {
return $post_link;
}
$instruction = "";
$read_only = "";
if (!IS_ADMIN) {
if (GFCommon::has_field_calculation($field)) {
// calculation-enabled fields should be read only
$read_only = 'readonly="readonly"';
} else {
$message = self::get_range_message($field);
$validation_class = $field["failed_validation"] ? "validation_message" : "";
if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
$instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
}
}
示例8: get_default_value
public static function get_default_value($field, $input_id)
{
if (!is_array($field->choices)) {
// if entry is saved in separate inputs get requsted input's default value ($input_id = 2.1)
// some fields (like Date, Time) do not save their values in separate inputs and are correctly filtered out by this condition ($input_id = 2)
// other fields (like Email w/ Confirm-enabled) also do not save their values in separate inputs but *should be* processed as input-specific submissions ($input_id = 2)
if (is_array($field->get_entry_inputs()) || $field->get_input_type() == 'email' && is_array($field->inputs)) {
$input = RGFormsModel::get_input($field, $input_id);
return rgar($input, 'defaultValue');
} else {
$value = $field->get_value_default();
if (!IS_ADMIN) {
if (is_array($value)) {
foreach ($value as &$_value) {
$_value = GFCommon::replace_variables_prepopulate($_value);
}
} else {
$value = GFCommon::replace_variables_prepopulate($value);
}
}
return $value;
}
} else {
if ($field->type == 'checkbox') {
for ($i = 0, $count = sizeof($field->inputs); $i < $count; $i++) {
$input = $field->inputs[$i];
$choice = $field->choices[$i];
if ($input['id'] == $input_id && rgar($choice, 'isSelected')) {
return $choice['value'];
}
}
return '';
} else {
foreach ($field->choices as $choice) {
if (rgar($choice, 'isSelected') || $field->type == 'post_category') {
return $choice['value'];
}
}
return '';
}
}
}
示例9: get_input_placeholder_value
public function get_input_placeholder_value($input)
{
$placeholder = rgar($input, 'placeholder');
return empty($placeholder) ? '' : GFCommon::replace_variables_prepopulate($placeholder);
}
示例10: get_field_content
public static function get_field_content($field, $value = "", $force_frontend_label = false, $form_id = 0)
{
$id = $field["id"];
$size = $field["size"];
$validation_message = rgget("failed_validation", $field) && !empty($field["validation_message"]) ? sprintf("<div class='gfield_description validation_message'>%s</div>", $field["validation_message"]) : "";
$delete_field_link = "<a class='field_delete_icon' id='gfield_delete_{$id}' title='" . __("click to delete this field", "gravityforms") . "' href='javascript:void(0);' onclick='StartDeleteField(this);'>" . __("Delete", "gravityforms") . "</a>";
$delete_field_link = apply_filters("gform_delete_field_link", $delete_field_link);
$admin_buttons = IS_ADMIN ? $delete_field_link . " <a class='field_edit_icon edit_icon_collapsed' href='javascript:void(0);' title='" . __("click to edit this field", "gravityforms") . "'>" . __("Edit", "gravityforms") . "</a>" : "";
$field_label = $force_frontend_label ? $field["label"] : GFCommon::get_label($field);
$field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
$required_div = IS_ADMIN || $field["isRequired"] ? sprintf("<span class='gfield_required'>%s</span>", $field["isRequired"] ? "*" : "") : "";
$target_input_id = "";
switch (RGFormsModel::get_input_type($field)) {
case "section":
$description = self::get_description(rgget("description", $field), "gsection_description");
$field_content = sprintf("%s<h2 class='gsection_title'>%s</h2>%s", $admin_buttons, esc_html($field_label), $description);
break;
case "page":
//only executed on the form editor in the admin
$page_label = __("Page Break", "gravityforms");
$src = GFCommon::get_base_url() . "/images/gf_pagebreak_inline.png";
$field_content = "{$admin_buttons} <label class='gfield_label'> </label><img src='{$src}' alt='{$page_label}' title='{$page_label}' />";
break;
case "adminonly_hidden":
case "hidden":
case "html":
$field_content = !IS_ADMIN ? "{FIELD}" : ($field_content = sprintf("%s<label class='gfield_label' for='%s'>%s</label>{FIELD}", $admin_buttons, $field_id, esc_html($field_label)));
break;
case "checkbox":
case "radio":
$description = self::get_description(rgget("description", $field), "gfield_description");
$field_content = sprintf("%s<label class='gfield_label'>%s%s</label>{FIELD}%s%s", $admin_buttons, esc_html($field_label), $required_div, $description, $validation_message);
break;
case "name":
$target_input_id = $field_id . ".3";
case "address":
if (empty($target_input_id)) {
$target_input_id = $field_id . "_1";
}
default:
if (empty($target_input_id)) {
$target_input_id = $field_id;
}
$description = self::get_description(rgget("description", $field), "gfield_description");
$field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>{FIELD}%s%s", $admin_buttons, $target_input_id, esc_html($field_label), $required_div, $description, $validation_message);
break;
}
if (empty($value)) {
$value = IS_ADMIN ? rgget("defaultValue", $field) : GFCommon::replace_variables_prepopulate(rgget("defaultValue", $field));
}
$field_content = str_replace("{FIELD}", GFCommon::get_field_input($field, $value, 0, $form_id), $field_content);
return $field_content;
}
示例11: get_field_content
public static function get_field_content($field, $value = "", $force_frontend_label = false, $form_id = 0)
{
$id = $field["id"];
$size = $field["size"];
$validation_message = $field["failed_validation"] && !empty($field["validation_message"]) ? sprintf("<div class='gfield_description validation_message'>%s</div>", $field["validation_message"]) : "";
$delete_field_link = "<a class='field_delete_icon' id='gfield_delete_{$id}' title='" . __("click to delete this field", "gravityforms") . "' href='javascript:void(0);' onclick='StartDeleteField(this);'>" . __("Delete", "gravityforms") . "</a>";
$delete_field_link = apply_filters("gform_delete_field_link", $delete_field_link);
$admin_buttons = IS_ADMIN ? $delete_field_link . " <a class='field_edit_icon edit_icon_collapsed' href='javascript:void(0);' title='" . __("click to edit this field", "gravityforms") . "'>" . __("Edit", "gravityforms") . "</a>" : "";
$field_label = $force_frontend_label ? $field["label"] : GFCommon::get_label($field);
$field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
$required_div = IS_ADMIN || $field["isRequired"] ? sprintf("<span class='gfield_required'>%s</span>", $field["isRequired"] ? "*" : "") : "";
switch (RGFormsModel::get_input_type($field)) {
case "section":
$description = self::get_description($field["description"], "gsection_description");
$field_content = sprintf("%s<h2 class='gsection_title'>%s</h2>%s", $admin_buttons, esc_html($field_label), $description);
break;
case "adminonly_hidden":
case "hidden":
$field_content = !IS_ADMIN ? "{FIELD}" : ($field_content = sprintf("%s<label class='gfield_label' for='%s'>%s</label>{FIELD}", $admin_buttons, $field_id, esc_html($field_label)));
break;
default:
$description = self::get_description($field["description"], "gfield_description");
$field_content = sprintf("%s<label class='gfield_label' for='%s'>%s%s</label>{FIELD}%s%s", $admin_buttons, $field_id, esc_html($field_label), $required_div, $description, $validation_message);
break;
}
if (empty($value)) {
$value = IS_ADMIN ? $field["defaultValue"] : GFCommon::replace_variables_prepopulate($field["defaultValue"]);
}
$field_content = str_replace("{FIELD}", GFCommon::get_field_input($field, $value, 0, $form_id), $field_content);
return $field_content;
}
示例12: gw_prepopluate_merge_tags
function gw_prepopluate_merge_tags($form)
{
$filter_names = array();
foreach ($form['fields'] as &$field) {
if (!rgar($field, 'allowsPrepopulate')) {
continue;
}
// complex fields store inputName in the "name" property of the inputs array
if (is_array(rgar($field, 'inputs')) && $field['type'] != 'checkbox') {
foreach ($field['inputs'] as $input) {
if (rgar($input, 'name')) {
$filter_names[] = array('type' => $field['type'], 'name' => rgar($input, 'name'));
}
}
} else {
$filter_names[] = array('type' => $field['type'], 'name' => rgar($field, 'inputName'));
}
}
foreach ($filter_names as $filter_name) {
$filtered_name = GFCommon::replace_variables_prepopulate($filter_name['name']);
if ($filter_name['name'] == $filtered_name) {
continue;
}
add_filter("gform_field_value_{$filter_name['name']}", create_function("", "return '{$filtered_name}';"));
}
return $form;
}
示例13: get_default_value
private static function get_default_value($field, $input_id)
{
if (!is_array($field["choices"])) {
return IS_ADMIN ? $field["defaultValue"] : GFCommon::replace_variables_prepopulate($field["defaultValue"]);
} else {
if ($field["type"] == "checkbox") {
for ($i = 0, $count = sizeof($field["inputs"]); $i < $count; $i++) {
$input = $field["inputs"][$i];
$choice = $field["choices"][$i];
if ($input["id"] == $input_id && $choice["isSelected"]) {
return $choice["value"];
}
}
return "";
} else {
foreach ($field["choices"] as $choice) {
if ($choice["isSelected"]) {
return $choice["text"];
}
}
return "";
}
}
}
示例14: get_field_input
//.........这里部分代码省略.........
}
else{
$logic_event = self::get_logic_event($field, "keyup");
if(rgget("emailConfirmEnabled", $field) && RG_CURRENT_VIEW != "entry"){
$first_tabindex = self::get_tabindex();
$last_tabindex = self::get_tabindex();
return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$logic_event} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email",__("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . esc_attr(rgpost("input_" . $id ."_2")) . "' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm",__("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span><div class='gf_clear gf_clear_complex'></div></div>";
}
else{
$tabindex = self::get_tabindex();
return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} {$logic_event} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
}
}
break;
case "honeypot":
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : "";
return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
break;
case "hidden" :
if(!empty($post_link))
return $post_link;
$field_type = IS_ADMIN ? "text" : "hidden";
$class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
return sprintf("<input name='input_%d' id='%s' type='$field_type' $class_attribute value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
break;
case "html" :
$content = IS_ADMIN ? "<div class='gf-html-container'><span class='gf_blockheader'><i class='fa fa-code fa-lg'></i> " . __("HTML Content", "gravityforms") . "</span><span>" . __("This is a content placeholder. HTML content is not displayed in the form admin. Preview this form to view the content.", "gravityforms") . "</span></div>" : $field["content"];
$content = GFCommon::replace_variables_prepopulate($content); //adding support for merge tags
$content = do_shortcode($content); //adding support for shortcodes
return $content;
break;
case "adminonly_hidden" :
if(!is_array($field["inputs"])){
if(is_array($value))
$value = json_encode($value);
return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
}
$fields = "";
foreach($field["inputs"] as $input){
$fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr(rgar($value, strval($input["id"]))));
}
return $fields;
break;
case "number" :
if(!empty($post_link))
return $post_link;
$instruction = "";
$read_only = "";
if(!IS_ADMIN){
if(GFCommon::has_field_calculation($field)) {
// calculation-enabled fields should be read only
$read_only = 'readonly="readonly"';