本文整理汇总了PHP中RGFormsModel::add_default_properties方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::add_default_properties方法的具体用法?PHP RGFormsModel::add_default_properties怎么用?PHP RGFormsModel::add_default_properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::add_default_properties方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gform_column_splits
function gform_column_splits($content, $field, $value, $lead_id, $form_id)
{
if (IS_ADMIN) {
return $content;
}
// only modify HTML on the front end
$form = RGFormsModel::get_form_meta($form_id, true);
$form_class = array_key_exists('cssClass', $form) ? $form['cssClass'] : '';
$form_classes = preg_split('/[\\n\\r\\t ]+/', $form_class, -1, PREG_SPLIT_NO_EMPTY);
$fields_class = array_key_exists('cssClass', $field) ? $field['cssClass'] : '';
$field_classes = preg_split('/[\\n\\r\\t ]+/', $fields_class, -1, PREG_SPLIT_NO_EMPTY);
if (!is_admin()) {
// multi-column form functionality
if ($field['type'] == 'section') {
$form = RGFormsModel::get_form_meta($form_id, true);
// check for the presence of multi-column form classes
$form_class = explode(' ', $form['cssClass']);
$form_class_matches = array_intersect($form_class, array('two-column', 'three-column'));
// check for the presence of section break column classes
$field_class = explode(' ', $field['cssClass']);
$field_class_matches = array_intersect($field_class, array('gform_column'));
// if field is a column break in a multi-column form, perform the list split
if (!empty($form_class_matches) && !empty($field_class_matches)) {
// make sure to target only multi-column forms
// retrieve the form's field list classes for consistency
$form = RGFormsModel::add_default_properties($form);
$description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
// close current field's li and ul and begin a new list with the same form field list classes
return '</li></ul><ul class="gform_fields ' . $form['labelPlacement'] . ' ' . $description_class . ' ' . $field['cssClass'] . '"><li class="gfield gsection empty">';
}
}
}
return $content;
}
示例2: _get_form_strings
function _get_form_strings($form_id)
{
$form = RGFormsModel::get_form_meta($form_id, true);
$form = RGFormsModel::add_default_properties($form);
$string_data = array();
$form_keys = array('title', 'description', 'limitEntriesMessage', 'scheduleMessage', 'postTitleTemplate', 'postContentTemplate', 'confirmation-message', 'autoResponder-subject', 'autoResponder-message', 'button-text');
foreach ($form_keys as $key) {
$parts = explode('-', $key);
if (sizeof($parts) == 1) {
if (isset($form[$key]) && $form[$key] != '') {
$string_data[$key] = $form[$key];
}
} else {
if (isset($form[$parts[0]][$parts[1]]) && $form[$parts[0]][$parts[1]] != '') {
$string_data[$key] = $form[$parts[0]][$parts[1]];
}
}
}
///- Paging Page Names - $form["pagination"]["pages"][i]
$keys = array('label', 'description', 'defaultValue', 'errorMessage');
foreach ($form['fields'] as $id => $field) {
foreach ($keys as $key) {
if (isset($field[$key]) && $field[$key] != '') {
$string_data['field-' . $field['id'] . '-' . $key] = $field[$key];
}
}
switch ($field['type']) {
case 'text':
case 'textarea':
case 'email':
case 'number':
case 'section':
break;
case 'html':
$string_data['field-' . $field['id'] . '-content'] = $field['content'];
break;
case 'page':
$string_data['field-' . $field['id'] . '-nextButton'] = $field['nextButton']['text'];
$string_data['field-' . $field['id'] . '-previousButton'] = $field['previousButton']['text'];
break;
case 'select':
case 'checkbox':
case 'radio':
case 'product':
if (isset($field['choices']) && is_array($field['choices'])) {
foreach ($field['choices'] as $index => $choice) {
$string_data['field-' . $field['id'] . '-choice-' . $choice['value']] = $choice['text'];
}
}
break;
case 'post_custom_field':
$string_data['field-' . $field['id'] . '-customFieldTemplate'] = $field["customFieldTemplate"];
break;
}
}
return $string_data;
}
示例3: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
{
//looking up form id by form name
if (!is_numeric($form_id)) {
$form_id = RGFormsModel::get_form_id($form_id);
}
//reading form metadata
$form = RGFormsModel::get_form_meta($form_id, true);
$form = RGFormsModel::add_default_properties($form);
//disable ajax if form has a reCAPTCHA field (not supported).
if ($ajax && self::has_recaptcha_field($form)) {
$ajax = false;
}
$is_postback = false;
$is_valid = true;
$confirmation_message = "";
$page_number = 1;
//If form was submitted, read variables set during form submission procedure
$submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
if ($submission_info) {
$is_postback = true;
$is_valid = rgar($submission_info, "is_valid") || rgar($submission_info, "is_confirmation");
$form = $submission_info["form"];
$lead = $submission_info["lead"];
$confirmation_message = rgget("confirmation_message", $submission_info);
if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
if ($submission_info["page_number"] == 0) {
//post submission hook
do_action("gform_post_submission", $lead, $form);
do_action("gform_post_submission_{$form["id"]}", $lead, $form);
} else {
//change page hook
do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
}
}
} else {
if (!current_user_can("administrator")) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
if (rgar($form, "enableHoneypot")) {
$form["fields"][] = self::get_honeypot_field($form);
}
//Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
$form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form, $ajax), $ajax);
if ($form == null) {
return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
}
$has_pages = self::has_pages($form);
//calling tab index filter
GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", $tabindex, $form), $form);
//Don't display inactive forms
if (!$force_display && !$is_postback) {
$form_info = RGFormsModel::get_form($form_id);
if (!$form_info->is_active) {
return "";
}
// If form requires login, check if user is logged in
if (rgar($form, "requireLogin")) {
if (!is_user_logged_in()) {
return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
}
}
}
// show the form regardless of the following validations when force display is set to true
if (!$force_display) {
$form_schedule_validation = self::validate_form_schedule($form);
// if form schedule validation fails AND this is not a postback, display the validation error
// if form schedule validation fails AND this is a postback, make sure is not a valid submission (enables display of confirmation message)
if ($form_schedule_validation && !$is_postback || $form_schedule_validation && $is_postback && !$is_valid) {
return $form_schedule_validation;
}
$entry_limit_validation = self::validate_entry_limit($form);
// refer to form schedule condition notes above
if ($entry_limit_validation && !$is_postback || $entry_limit_validation && $is_postback && !$is_valid) {
return $entry_limit_validation;
}
}
$form_string = "";
//When called via a template, this will enqueue the proper scripts
//When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
self::enqueue_form_scripts($form, $ajax);
if (empty($confirmation_message)) {
$wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
if (!$is_valid) {
$wrapper_css_class .= " gform_validation_error";
}
//Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
$style = self::has_conditional_logic($form) ? "style='display:none'" : "";
$custom_wrapper_css_class = !empty($form["cssClass"]) ? " {$form["cssClass"]}_wrapper" : "";
$form_string .= "\n <div class='{$wrapper_css_class}{$custom_wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
$action = add_query_arg(array());
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
if ($use_anchor !== false) {
$form_string .= "<a id='gf_{$form_id}' name='gf_{$form_id}' class='gform_anchor' ></a>";
$action .= "#gf_{$form_id}";
}
$target = $ajax ? "target='gform_ajax_frame_{$form_id}'" : "";
//.........这里部分代码省略.........
示例4: 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;
}
示例5: get_form
public static function get_form($form_id, $display_title = true, $display_description = true, $force_display = false, $field_values = null, $ajax = false, $tabindex = 1)
{
//looking up form id by form name
if (!is_numeric($form_id)) {
$form_id = RGFormsModel::get_form_id($form_id);
}
//reading form metadata
$form = RGFormsModel::get_form_meta($form_id, true);
$form = RGFormsModel::add_default_properties($form);
//disable ajax if form has a reCAPTCHA field (not supported).
if ($ajax && self::has_recaptcha_field($form)) {
$ajax = false;
}
$is_postback = false;
$is_valid = true;
$confirmation_message = "";
$page_number = 1;
//If form was submitted, read variables set during form submission procedure
$submission_info = isset(self::$submission[$form_id]) ? self::$submission[$form_id] : false;
if ($submission_info) {
$is_postback = true;
$is_valid = $submission_info["is_valid"] || rgget("is_confirmation", $submission_info);
$form = $submission_info["form"];
$lead = $submission_info["lead"];
$confirmation_message = rgget("confirmation_message", $submission_info);
if ($is_valid && !RGForms::get("is_confirmation", $submission_info)) {
if ($submission_info["page_number"] == 0) {
//post submission hook
do_action("gform_post_submission", $lead, $form);
do_action("gform_post_submission_{$form["id"]}", $lead, $form);
} else {
//change page hook
do_action("gform_post_paging", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
do_action("gform_post_paging_{$form["id"]}", $form, $submission_info["source_page_number"], $submission_info["page_number"]);
}
}
} else {
if (!current_user_can("administrator")) {
RGFormsModel::insert_form_view($form_id, $_SERVER['REMOTE_ADDR']);
}
}
if (rgar($form, "enableHoneypot")) {
$form["fields"][] = self::get_honeypot_field($form);
}
//Fired right before the form rendering process. Allow users to manipulate the form object before it gets displayed in the front end
$form = apply_filters("gform_pre_render_{$form_id}", apply_filters("gform_pre_render", $form));
if ($form == null) {
return "<p>" . __("Oops! We could not locate your form.", "gravityforms") . "</p>";
}
$has_pages = self::has_pages($form);
//calling tab index filter
GFCommon::$tab_index = apply_filters("gform_tabindex_{$form_id}", apply_filters("gform_tabindex", $tabindex, $form), $form);
//Don't display inactive forms
if (!$force_display && !$is_postback) {
$form_info = RGFormsModel::get_form($form_id);
if (!$form_info->is_active) {
return "";
}
//If form has a schedule, make sure it is within the configured start and end dates
if (rgar($form, "scheduleForm")) {
$local_time_start = sprintf("%s %02d:%02d %s", $form["scheduleStart"], $form["scheduleStartHour"], $form["scheduleStartMinute"], $form["scheduleStartAmpm"]);
$local_time_end = sprintf("%s %02d:%02d %s", $form["scheduleEnd"], $form["scheduleEndHour"], $form["scheduleEndMinute"], $form["scheduleEndAmpm"]);
$timestamp_start = strtotime($local_time_start . ' +0000');
$timestamp_end = strtotime($local_time_end . ' +0000');
$now = current_time("timestamp");
if (!empty($form["scheduleStart"]) && $now < $timestamp_start || !empty($form["scheduleEnd"]) && $now > $timestamp_end) {
return empty($form["scheduleMessage"]) ? "<p>" . __("Sorry. This form is no longer available.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["scheduleMessage"]) . "</p>";
}
}
//If form has a limit of entries, check current entry count
if (rgar($form, "limitEntries")) {
$period = rgar($form, "limitEntriesPeriod");
$range = self::get_limit_period_dates($period);
$entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $range["start_date"], $range["end_date"]);
if ($entry_count >= $form["limitEntriesCount"]) {
return empty($form["limitEntriesMessage"]) ? "<p>" . __("Sorry. This form is no longer accepting new submissions.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["limitEntriesMessage"]) . "</p>";
}
}
// If form requires login, check if user is logged in
if (rgar($form, "requireLogin")) {
if (!is_user_logged_in()) {
return empty($form["requireLoginMessage"]) ? "<p>" . __("Sorry. You must be logged in to view this form.", "gravityforms") . "</p>" : "<p>" . GFCommon::gform_do_shortcode($form["requireLoginMessage"]) . "</p>";
}
}
}
$form_string = "";
//When called via a template, this will enqueue the proper scripts
//When called via a shortcode, this will be ignored (too late to enqueue), but the scripts will be enqueued via the enqueue_scripts event
self::enqueue_form_scripts($form, $ajax);
if (empty($confirmation_message)) {
$wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper";
if (!$is_valid) {
$wrapper_css_class .= " gform_validation_error";
}
//Hidding entire form if conditional logic is on to prevent "hidden" fields from blinking. Form will be set to visible in the conditional_logic.php after the rules have been applied.
$style = self::has_conditional_logic($form) ? "style='display:none'" : "";
$form_string .= "\n <div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' " . $style . ">";
$action = add_query_arg(array());
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = apply_filters("gform_confirmation_anchor_{$form["id"]}", apply_filters("gform_confirmation_anchor", $default_anchor));
//.........这里部分代码省略.........
示例6: forms_page
//.........这里部分代码省略.........
for(var i=0; i<form["fields"].length; i++){
if(form["fields"][i]["id"] == field_id){
if(form["fields"][i]["type"] == "post_image"){
jQuery('#' + element_id + '_image_size_select').attr("variable", variable);
jQuery('#' + element_id + '_image_size_select').show();
return;
}
}
}
InsertVariable(element_id, callback);
}
</script>
<style>
.field_type li {
float:left;
width:50%;
}
.field_type input{
width:100px;
}
.description-list { margin: 10px 0; padding: 0 20px; }
.description-list li { padding: 0; list-style: disc; overflow: visible; }
.custom_mask_instructions h5 { margin: 0 0 4px; font-size: 11px; }
.custom_mask_instructions span.label { font-size: 11px; display: -moz-inline-stack; display: inline-block; zoom: 1; *display: inline;
width: 80px; }
.custom_mask_instructions li { margin: 0 0 14px; }
</style>
<?php
$form = !rgempty("meta", $update_result) ? rgar($update_result, "meta") : RGFormsModel::get_form_meta($form_id);
$form = RGFormsModel::add_default_properties($form);
if ($form == null) {
$form = array("fields" => array());
}
$form = apply_filters("gform_admin_pre_render_" . $form_id, apply_filters("gform_admin_pre_render", $form));
if (isset($form['id'])) {
echo "<script type=\"text/javascript\">var form = " . GFCommon::json_encode($form) . ";</script>";
} else {
echo "<script type=\"text/javascript\">var form = new Form();</script>";
}
?>
<?php
echo GFCommon::get_remote_message();
?>
<div class="wrap gforms_edit_form <?php
echo GFCommon::get_browser_class();
?>
">
<div class="icon32" id="gravity-edit-icon"><br></div>
<h2><?php
echo empty($form_id) ? __("New Form", "gravityforms") : __("Form Editor :", "gravityforms") . " " . esc_html($form["title"]);
?>
</h2>
<?php
RGForms::top_toolbar();
?>
示例7: forms_page
//.........这里部分代码省略.........
}
}
}
InsertVariable(element_id, callback);
}
function IsValidFormula(formula){
if(formula == '')
return true;
var patt = /{([^}]+)}/i,
exprPatt = /^[0-9 -/*\(\)]+$/i,
expr = formula.replace(/(\r\n|\n|\r)/gm,""),
match;
while(match = patt.exec(expr)) {
expr = expr.replace(match[0], 1);
}
if(exprPatt.test(expr)) {
try {
var r = eval(expr);
return !isNaN(parseFloat(r)) && isFinite(r);
} catch (e) {
return false;
}
} else {
return false;
}
}
</script>
<?php
$form = !rgempty("meta", $update_result) ? rgar($update_result, "meta") : GFFormsModel::get_form_meta($form_id);
$form = RGFormsModel::add_default_properties($form);
if (!isset($form['fields']) || !is_array($form['fields'])) {
$form["fields"] = array();
}
$form = apply_filters("gform_admin_pre_render_" . $form_id, apply_filters("gform_admin_pre_render", $form));
if (isset($form['id'])) {
echo "<script type=\"text/javascript\">var form = " . GFCommon::json_encode($form) . ";</script>";
} else {
echo "<script type=\"text/javascript\">var form = new Form();</script>";
}
?>
<?php
echo GFCommon::get_remote_message();
?>
<div class="wrap gforms_edit_form <?php
echo GFCommon::get_browser_class();
?>
">
<?php
if (empty($form_id)) {
?>
<h2 class="gf_admin_page_title"><?php
_e("New Form", "gravityforms");
?>
</h2>
<?php
} else {
?>
<h2 class="gf_admin_page_title"><span><?php
_e("Form Editor", "gravityforms");
?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php
示例8: gform_column_splits
function gform_column_splits($content, $field, $value, $lead_id, $form_id)
{
if (!IS_ADMIN) {
// only perform on the front end
// target section breaks
if ($field['type'] == 'section') {
$form = RGFormsModel::get_form_meta($form_id, true);
// check for the presence of our special multi-column form class
$form_class = explode(' ', $form['cssClass']);
$form_class_matches = array_intersect($form_class, array('two-column'));
// check for the presence of our special section break column class
$field_class = explode(' ', $field['cssClass']);
$field_class_matches = array_intersect($field_class, array('gform_column'));
// if we have a column break field in a multi-column form, perform the list split
if (!empty($form_class_matches) && !empty($field_class_matches)) {
// we'll need to retrieve the form's properties for consistency
$form = RGFormsModel::add_default_properties($form);
$description_class = rgar($form, 'descriptionPlacement') == 'above' ? 'description_above' : 'description_below';
// close current field's li and ul and begin a new list with the same form properties
return '</li></ul><ul class="gform_fields ' . $form['labelPlacement'] . ' ' . $description_class . ' ' . $field['cssClass'] . '"><li class="gfield gsection">';
}
}
}
return $content;
}
示例9: show_field_ids
static function show_field_ids($form = array())
{
if (isset($_REQUEST['show_field_ids'])) {
$form = RGFormsModel::get_form_meta($_GET["id"]);
$form = RGFormsModel::add_default_properties($form);
echo <<<EOD
\t\t<style>
\t\t\t#input_ids th, #input_ids td { border-bottom:1px solid #999; padding:.25em 15px; }
\t\t\t#input_ids th { border-bottom-color: #333; font-size:.9em; background-color: #464646; color:white; padding:.5em 15px; font-weight:bold; }
\t\t\t#input_ids { background:#ccc; margin:0 auto; font-size:1.2em; line-height:1.4; width:100%; border-collapse:collapse; }
\t\t\t#input_ids strong { font-weight:bold; }
\t\t\t#input_ids caption,
\t\t\t#preview_hdr { display:none;}
\t\t\t#input_ids caption { color:white!important;}
\t\t</style>
EOD;
if (!empty($form)) {
echo '<table id="input_ids"><caption id="input_id_caption">Fields for <strong>Form ID ' . $form['id'] . '</strong></caption><thead><tr><th>Field Name</th><th>Field ID</th></thead><tbody>';
}
foreach ($form['fields'] as $field) {
// If there are multiple inputs for a field; ie: address has street, city, zip, country, etc.
if (is_array($field['inputs'])) {
foreach ($field['inputs'] as $input) {
echo "<tr><td width='50%'><strong>{$input['label']}</strong></td><td>{$input['id']}</td></tr>";
}
} else {
echo "<tr><td width='50%'><strong>{$field['label']}</strong></td><td>{$field['id']}</td></tr>";
}
}
if (!empty($form)) {
echo '</tbody></table><div style="clear:both;"></div></body></html>';
exit;
}
} else {
return $form;
}
}
示例10: _get_form_strings
function _get_form_strings($form_id)
{
$form = RGFormsModel::get_form_meta($form_id, true);
$form = RGFormsModel::add_default_properties($form);
$string_data = array();
$form_keys = $this->_get_form_keys();
foreach ($form_keys as $key) {
$parts = explode('-', $key);
if (sizeof($parts) == 1) {
if (isset($form[$key]) && $form[$key] != '') {
$string_data[$key] = $form[$key];
}
} else {
if (isset($form[$parts[0]][$parts[1]]) && $form[$parts[0]][$parts[1]] != '') {
$string_data[$key] = $form[$parts[0]][$parts[1]];
}
}
}
///- Paging Page Names - $form["pagination"]["pages"][i]
if (isset($form["pagination"])) {
foreach ($form['pagination']['pages'] as $key => $page_title) {
$string_data['page-' . ($key + 1) . '-title'] = $page_title;
}
}
//Fields (including paging fields)
$keys = $this->_get_field_keys();
foreach ($form['fields'] as $id => $field) {
if ($field['type'] != 'page') {
foreach ($keys as $key) {
if (isset($field[$key]) && $field[$key] != '') {
$string_data['field-' . $field['id'] . '-' . $key] = $field[$key];
}
}
}
switch ($field['type']) {
case 'text':
case 'textarea':
case 'email':
case 'number':
case 'section':
break;
case 'html':
$string_data[$form['id'] . '_field-' . $field['id'] . '-content'] = $field['content'];
break;
case 'page':
// page breaks are stored as belonging to the next page,
// but their buttons are actually displayed in the previous page
foreach (array('text', 'imageUrl') as $key) {
if (isset($form['fields'][$id]['nextButton'][$key])) {
$string_data['page-' . ($field['pageNumber'] - 1) . '-nextButton-' . $key] = $field['nextButton'][$key];
}
if (isset($form['fields'][$id]['previousButton'][$key])) {
$string_data['page-' . ($field['pageNumber'] - 1) . '-previousButton-' . $key] = $field['previousButton'][$key];
}
}
break;
case 'select':
case 'multiselect':
case 'checkbox':
case 'radio':
case 'list':
if (!empty($field['choices'])) {
foreach ($field['choices'] as $index => $choice) {
$string_name = substr('field-' . $field['id'] . '-choice-' . $choice['text'], 0, 158);
$string_data[$string_name] = $choice['text'];
}
}
break;
case 'product':
case 'option':
if (!empty($field['choices'])) {
foreach ($field['choices'] as $index => $choice) {
$string_name = substr('product-' . $field['id'] . '-choice-' . $choice['text'], 0, 158);
$string_data[$string_name] = $choice['text'];
if (isset($choice['price'])) {
$string_data[$string_name . '-price'] = $choice['price'];
}
}
} elseif (isset($field['basePrice'])) {
$string_data['product-' . $field['id'] . '-basePrice'] = $field['basePrice'];
}
break;
case 'post_custom_field':
$string_data['field-' . $field['id'] . '-customFieldTemplate'] = $field["customFieldTemplate"];
break;
case 'post_category':
if (isset($field["categoryInitialItem"])) {
$string_data['field-' . $field['id'] . '-categoryInitialItem'] = $field["categoryInitialItem"];
}
break;
}
}
// confirmations
foreach ($form['confirmations'] as $key => $confirm) {
switch ($confirm['type']) {
case 'message':
$string_data["field-confirmation-message_" . $confirm['name']] = $confirm['message'];
//add prefix 'field-' to get a textarea editor box
break;
case 'redirect':
//.........这里部分代码省略.........
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:101,代码来源:gravity_forms_multilingual.class.php