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


PHP FrmFieldsHelper类代码示例

本文整理汇总了PHP中FrmFieldsHelper的典型用法代码示例。如果您正苦于以下问题:PHP FrmFieldsHelper类的具体用法?PHP FrmFieldsHelper怎么用?PHP FrmFieldsHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: duplicate

 public static function duplicate($old_form_id, $form_id, $copy_keys = false, $blog_id = false)
 {
     global $frm_duplicate_ids;
     $fields = self::getAll(array('fi.form_id' => $old_form_id), 'field_order', '', $blog_id);
     foreach ((array) $fields as $field) {
         $new_key = $copy_keys ? $field->field_key : '';
         if ($copy_keys && substr($field->field_key, -1) == 2) {
             $new_key = rtrim($new_key, 2);
         }
         $values = array();
         FrmFieldsHelper::fill_field($values, $field, $form_id, $new_key);
         // If this is a repeating section, create new form
         if (self::is_repeating_field($field)) {
             // create the repeatable form
             $new_repeat_form_id = apply_filters('frm_create_repeat_form', 0, array('parent_form_id' => $form_id, 'field_name' => $field->name));
             // Save old form_select
             $old_repeat_form_id = $field->field_options['form_select'];
             // Update form_select for repeating field
             $values['field_options']['form_select'] = $new_repeat_form_id;
         }
         // If this is a field inside of a repeating section, associate it with the correct form
         if ($field->form_id != $old_form_id && isset($old_repeat_form_id) && isset($new_repeat_form_id) && $field->form_id == $old_repeat_form_id) {
             $values['form_id'] = $new_repeat_form_id;
         }
         $values = apply_filters('frm_duplicated_field', $values);
         $new_id = self::create($values);
         $frm_duplicate_ids[$field->id] = $new_id;
         $frm_duplicate_ids[$field->field_key] = $new_id;
         unset($field);
     }
 }
开发者ID:EyesX,项目名称:formidable-forms,代码行数:31,代码来源:FrmField.php

示例2: setup_edit_vars

 function setup_edit_vars($record)
 {
     global $frm_entry_meta, $frm_form;
     $values = array();
     $record->field_options = maybe_unserialize($record->field_options);
     $values['id'] = $record->id;
     $values['form_id'] = $record->form_id;
     foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default) {
         $values[$var] = htmlspecialchars(stripslashes(FrmAppHelper::get_param($var, $default)));
     }
     $values['form_name'] = $record->form_id ? $frm_form->getName($record->form_id) : '';
     foreach (array('field_key' => $record->field_key, 'type' => $record->type, 'default_value' => $record->default_value, 'field_order' => $record->field_order, 'required' => $record->required) as $var => $default) {
         $values[$var] = FrmAppHelper::get_param($var, $default);
     }
     $values['options'] = stripslashes_deep(maybe_unserialize($record->options));
     $values['field_options'] = $record->field_options;
     $defaults = FrmFieldsHelper::get_default_field_opts($values['type'], $record, true);
     if ($values['type'] == 'captcha') {
         global $frm_settings;
         $defaults['invalid'] = $frm_settings->re_msg;
     }
     foreach ($defaults as $opt => $default) {
         $values[$opt] = isset($record->field_options[$opt]) ? $record->field_options[$opt] : $default;
     }
     $values['custom_html'] = isset($record->field_options['custom_html']) ? stripslashes($record->field_options['custom_html']) : FrmFieldsHelper::get_default_html($record->type);
     return apply_filters('frm_setup_edit_field_vars', $values, $values['field_options']);
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:27,代码来源:FrmFieldsHelper.php

示例3: validate

 public static function validate($params, $fields, $form, $title, $description)
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     if (($_POST && isset($_POST['frm_page_order_' . $form->id]) || FrmProFormsHelper::going_to_prev($form->id)) && !FrmProFormsHelper::saving_draft()) {
         $errors = '';
         $fields = FrmFieldsHelper::get_form_fields($form->id);
         $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
         $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
         require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
         add_filter('frm_continue_to_create', '__return_false');
     } else {
         if ($form->editable && isset($form->options['single_entry']) && $form->options['single_entry'] && $form->options['single_entry_type'] == 'user') {
             $user_ID = get_current_user_id();
             if ($user_ID) {
                 $entry = FrmEntry::getAll(array('it.user_id' => $user_ID, 'it.form_id' => $form->id), '', 1, true);
                 if ($entry) {
                     $entry = reset($entry);
                 }
             } else {
                 $entry = false;
             }
             if ($entry && !empty($entry) && (!isset($frm_vars['created_entries'][$form->id]) || !isset($frm_vars['created_entries'][$form->id]['entry_id']) || $entry->id != $frm_vars['created_entries'][$form->id]['entry_id'])) {
                 FrmProEntriesController::show_responses($entry, $fields, $form, $title, $description);
             } else {
                 $record = $frm_vars['created_entries'][$form->id]['entry_id'];
                 $saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
                 if (FrmProFormsHelper::saving_draft()) {
                     $saved_message = isset($form->options['draft_msg']) ? $form->options['draft_msg'] : __('Your draft has been saved.', 'formidable');
                 }
                 $saved_message = apply_filters('frm_content', $saved_message, $form, $record ? $record : false);
                 $message = wpautop(do_shortcode($record ? $saved_message : $frm_settings->failed_msg));
                 $message = '<div class="frm_message" id="message">' . $message . '</div>';
                 FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
             }
             add_filter('frm_continue_to_create', '__return_false');
         } else {
             if (FrmProFormsHelper::saving_draft()) {
                 $record = isset($frm_vars['created_entries']) && isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
                 if (!$record) {
                     return;
                 }
                 $saved_message = '';
                 FrmProFormsHelper::save_draft_msg($saved_message, $form, $record);
                 $message = FrmFormsHelper::get_success_message(array('message' => $saved_message, 'form' => $form, 'entry_id' => $record, 'class' => 'frm_message'));
                 FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
                 add_filter('frm_continue_to_create', '__return_false');
             }
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:51,代码来源:FrmProEntry.php

示例4: get_description

 /**
  * Get description
  *
  * @see Pronamic_Pay_PaymentDataInterface::get_description()
  * @return string
  */
 public function get_description()
 {
     // Description template
     $description_template = $this->action->post_content['pronamic_pay_transaction_description'];
     // Find shortcode
     // @see https://github.com/wp-premium/formidable/blob/2.0.22/classes/helpers/FrmFieldsHelper.php#L684-L696
     $shortcodes = FrmFieldsHelper::get_shortcodes($description_template, $this->form_id);
     // Replace shortcodes
     // @see https://github.com/wp-premium/formidable/blob/2.0.22/classes/helpers/FrmFieldsHelper.php#L715-L821
     $description = FrmFieldsHelper::replace_content_shortcodes($description_template, $this->entry, $shortcodes);
     // Check if there was a replacement to make sure the description has a dynamic part
     if ($description_template === $description) {
         $description .= $this->entry_id;
     }
     return $description;
 }
开发者ID:wp-pay-extensions,项目名称:formidable-forms,代码行数:22,代码来源:PaymentData.php

示例5: setup_new_vars

 public static function setup_new_vars($fields, $form = '', $reset = false, $args = array())
 {
     global $frm_vars;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = FrmAppHelper::get_post_param($var, $default);
     }
     $values['fields'] = array();
     if (empty($fields)) {
         return apply_filters('frm_setup_new_entry', $values);
     }
     foreach ((array) $fields as $field) {
         $new_value = self::get_field_value_for_new_entry($field, $reset);
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id, 'parent_form_id' => isset($args['parent_form_id']) ? $args['parent_form_id'] : $field->form_id);
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         $opt_defaults['required_indicator'] = '';
         $opt_defaults['original_type'] = $field->type;
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
             unset($opt, $default_opt);
         }
         unset($opt_defaults);
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
         }
         $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
         $field_array = array_merge($field->field_options, $field_array);
         $values['fields'][] = $field_array;
         if (!$form || !isset($form->id)) {
             $form = FrmForm::getOne($field->form_id);
         }
     }
     $form->options = maybe_unserialize($form->options);
     if (is_array($form->options)) {
         foreach ($form->options as $opt => $value) {
             $values[$opt] = FrmAppHelper::get_post_param($opt, $value);
             unset($opt, $value);
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $frm_settings = FrmAppHelper::get_settings();
     $form_defaults['custom_style'] = $frm_settings->load_style != 'none';
     $values = array_merge($form_defaults, $values);
     return apply_filters('frm_setup_new_entry', $values);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:45,代码来源:FrmEntriesHelper.php

示例6: trigger_email

 public static function trigger_email($action, $entry, $form)
 {
     if (defined('WP_IMPORTING') && WP_IMPORTING) {
         return;
     }
     global $wpdb;
     $notification = $action->post_content;
     $email_key = $action->ID;
     // Set the subject
     if (empty($notification['email_subject'])) {
         $notification['email_subject'] = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, '[sitename]');
     }
     $plain_text = $notification['plain_text'] ? true : false;
     //Filter these fields
     $filter_fields = array('email_to', 'cc', 'bcc', 'reply_to', 'from', 'email_subject', 'email_message');
     add_filter('frm_plain_text_email', $plain_text ? '__return_true' : '__return_false');
     //Get all values in entry in order to get User ID field ID
     $values = FrmEntryMeta::getAll(array('it.field_id !' => 0, 'it.item_id' => $entry->id), ' ORDER BY fi.field_order');
     $user_id_field = $user_id_key = '';
     foreach ($values as $value) {
         if ($value->field_type == 'user_id') {
             $user_id_field = $value->field_id;
             $user_id_key = $value->field_key;
             break;
         }
         unset($value);
     }
     //Filter and prepare the email fields
     foreach ($filter_fields as $f) {
         //Don't allow empty From
         if ($f == 'from' && empty($notification[$f])) {
             $notification[$f] = '[admin_email]';
         } else {
             if (in_array($f, array('email_to', 'cc', 'bcc', 'reply_to', 'from'))) {
                 //Remove brackets
                 //Add a space in case there isn't one
                 $notification[$f] = str_replace('<', ' ', $notification[$f]);
                 $notification[$f] = str_replace(array('"', '>'), '', $notification[$f]);
                 //Switch userID shortcode to email address
                 if (strpos($notification[$f], '[' . $user_id_field . ']') !== false || strpos($notification[$f], '[' . $user_id_key . ']') !== false) {
                     $user_data = get_userdata($entry->metas[$user_id_field]);
                     $user_email = $user_data->user_email;
                     $notification[$f] = str_replace(array('[' . $user_id_field . ']', '[' . $user_id_key . ']'), $user_email, $notification[$f]);
                 }
             }
         }
         $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes($notification[$f], $form, $entry);
     }
     //Put recipients, cc, and bcc into an array if they aren't empty
     $to_emails = self::explode_emails($notification['email_to']);
     $cc = self::explode_emails($notification['cc']);
     $bcc = self::explode_emails($notification['bcc']);
     $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
     // Stop now if there aren't any recipients
     if (empty($to_emails) && empty($cc) && empty($bcc)) {
         return;
     }
     $to_emails = array_unique((array) $to_emails);
     $prev_mail_body = $mail_body = $notification['email_message'];
     $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
     // Add the user info if it isn't already included
     if ($notification['inc_user_info'] && $prev_mail_body == $mail_body) {
         $data = maybe_unserialize($entry->description);
         $mail_body .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n";
         $mail_body .= __('IP Address', 'formidable') . ': ' . $entry->ip . "\r\n";
         $mail_body .= __('User-Agent (Browser/OS)', 'formidable') . ': ' . FrmEntryFormat::get_browser($data['browser']) . "\r\n";
         $mail_body .= __('Referrer', 'formidable') . ': ' . $data['referrer'] . "\r\n";
     }
     unset($prev_mail_body);
     // Add attachments
     $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key'));
     if (!empty($notification['email_subject'])) {
         $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
     }
     // check for a phone number
     foreach ((array) $to_emails as $email_key => $e) {
         if ($e != '[admin_email]' && !is_email($e)) {
             $e = explode(' ', $e);
             //If to_email has name <test@mail.com> format
             if (is_email(end($e))) {
                 continue;
             }
             do_action('frm_send_to_not_email', array('e' => $e, 'subject' => $notification['email_subject'], 'mail_body' => $mail_body, 'reply_to' => $notification['reply_to'], 'from' => $notification['from'], 'plain_text' => $plain_text, 'attachments' => $attachments, 'form' => $form, 'email_key' => $email_key));
             unset($to_emails[$email_key]);
         }
     }
     // Send the email now
     $sent_to = self::send_email(array('to_email' => $to_emails, 'subject' => $notification['email_subject'], 'message' => $mail_body, 'from' => $notification['from'], 'plain_text' => $plain_text, 'reply_to' => $notification['reply_to'], 'attachments' => $attachments, 'cc' => $cc, 'bcc' => $bcc));
     return $sent_to;
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:90,代码来源:FrmNotification.php

示例7: do_action

                    if (!$frm_css_loaded and $frm_load_css) {
                        echo FrmAppController::footer_js('header');
                        $frm_css_loaded = true;
                    }
                    ?>
<div class="frm_forms<?php 
                    echo $values['custom_style'] ? ' with_frm_style' : '';
                    ?>
" id="frm_form_<?php 
                    echo $form->id;
                    ?>
_container"><?php 
                    echo $message;
                    ?>
</div>
<?php 
                }
            } else {
                do_action('frm_success_action', $conf_method, $form, $form->options, $created);
            }
            do_action('frm_after_entry_processed', array('entry_id' => $created, 'form' => $form));
        }
    }
} else {
    $fields = FrmFieldsHelper::get_form_fields($form->id);
    do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
    if (apply_filters('frm_continue_to_new', true, $form->id, $params['action'])) {
        $values = FrmEntriesHelper::setup_new_vars($fields, $form);
        require FRM_VIEWS_PATH . '/frm-entries/new.php';
    }
}
开发者ID:moscarar,项目名称:cityhow,代码行数:31,代码来源:frm-entry.php

示例8: get_edit_vars

 function get_edit_vars($id, $errors = '', $message = '')
 {
     if (!current_user_can('frm_edit_entries')) {
         return $this->show($id);
     }
     global $frm_form, $frm_entry, $frm_field, $frm_next_page, $frmpro_settings, $frm_editing_entry;
     $title = $description = true;
     $record = $frm_entry->getOne($id, true);
     $frm_editing_entry = $id;
     $form = $frm_form->getOne($record->form_id);
     $fields = FrmFieldsHelper::get_form_fields($form->id, !empty($errors));
     $values = FrmAppHelper::setup_edit_vars($record, 'entries', $fields);
     $submit = isset($frm_next_page[$form->id]) ? $frm_next_page[$form->id] : (isset($values['edit_value']) ? $values['edit_value'] : $frmpro_settings->update_value);
     require FRMPRO_VIEWS_PATH . '/frmpro-entries/edit.php';
 }
开发者ID:moscarar,项目名称:cityhow,代码行数:15,代码来源:FrmProEntriesController.php

示例9: replace_shortcodes

 public static function replace_shortcodes($html, $form, $title = false, $description = false, $values = array())
 {
     foreach (array('form_name' => $title, 'form_description' => $description, 'entry_key' => true) as $code => $show) {
         if ($code == 'form_name') {
             $replace_with = $form->name;
         } else {
             if ($code == 'form_description') {
                 $replace_with = FrmAppHelper::use_wpautop($form->description);
             } else {
                 if ($code == 'entry_key' && isset($_GET) && isset($_GET['entry'])) {
                     $replace_with = FrmAppHelper::simple_get('entry');
                 } else {
                     $replace_with = '';
                 }
             }
         }
         FrmFieldsHelper::remove_inline_conditions(FrmAppHelper::is_true($show) && $replace_with != '', $code, $replace_with, $html);
     }
     //replace [form_key]
     $html = str_replace('[form_key]', $form->form_key, $html);
     //replace [frmurl]
     $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values('frmurl'), $html);
     if (strpos($html, '[button_label]')) {
         add_filter('frm_submit_button', 'FrmFormsHelper::submit_button_label', 1);
         $replace_with = apply_filters('frm_submit_button', $title, $form);
         $html = str_replace('[button_label]', $replace_with, $html);
     }
     $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
     if (strpos($html, '[if back_button]')) {
         $html = preg_replace('/(\\[if\\s+back_button\\])(.*?)(\\[\\/if\\s+back_button\\])/mis', '', $html);
     }
     if (strpos($html, '[if save_draft]')) {
         $html = preg_replace('/(\\[if\\s+save_draft\\])(.*?)(\\[\\/if\\s+save_draft\\])/mis', '', $html);
     }
     if (apply_filters('frm_do_html_shortcodes', true)) {
         $html = do_shortcode($html);
     }
     return $html;
 }
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:39,代码来源:FrmFormsHelper.php

示例10: get_countries

 public static function get_countries()
 {
     _deprecated_function(__FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries');
     return FrmFieldsHelper::get_countries();
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:5,代码来源:FrmAppHelper.php

示例11: get_shortcodes

 public static function get_shortcodes($content, $form_id)
 {
     _deprecated_function(__FUNCTION__, '2.0', 'FrmFieldsHelper::get_shortcodes');
     return FrmFieldsHelper::get_shortcodes($content, $form_id);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:5,代码来源:FrmProAppHelper.php

示例12: migrate_to_6

    private function migrate_to_6()
    {
        global $wpdb;
        $no_save = array_merge(FrmField::no_save_fields(), array('form', 'hidden', 'user_id'));
        $fields = FrmDb::get_results($this->fields, array('type NOT' => $no_save), 'id, field_options');
        $default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
    <label class="frm_pos_[label_position]">[field_name]
        <span class="frm_required">[required_label]</span>
    </label>
    [input]
    [if description]<div class="frm_description">[description]</div>[/if description]
</div>
DEFAULT_HTML;
        $old_default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
    <label class="frm_pos_[label_position]">[field_name]
        <span class="frm_required">[required_label]</span>
    </label>
    [input]
    [if description]<p class="frm_description">[description]</p>[/if description]
</div>
DEFAULT_HTML;
        $new_default_html = FrmFieldsHelper::get_default_html('text');
        foreach ($fields as $field) {
            $field->field_options = maybe_unserialize($field->field_options);
            if (!FrmField::is_option_empty($field, 'custom_html') || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html) {
                $field->field_options['custom_html'] = $new_default_html;
                $wpdb->update($this->fields, array('field_options' => maybe_serialize($field->field_options)), array('id' => $field->id));
            }
            unset($field);
        }
        unset($default_html, $old_default_html, $fields);
    }
开发者ID:hugocica,项目名称:locomotiva-2016,代码行数:34,代码来源:FrmDb.php

示例13: get_shortcodes

 public static function get_shortcodes($content, $form_id)
 {
     if (empty($form_id) || strpos($content, '[') === false) {
         // don't continue if there are no shortcodes to check
         return array(array());
     }
     $tagregexp = array('deletelink', 'detaillink', 'evenodd', 'get', 'entry_count', 'event_date');
     $form_id = (int) $form_id;
     $form_ids = array($form_id);
     //get linked form ids
     $fields = FrmProFormsHelper::has_repeat_field($form_id, false);
     foreach ($fields as $field) {
         if (FrmField::is_option_true($field, 'form_select')) {
             $form_ids[] = $field->field_options['form_select'];
             $tagregexp[] = $field->id;
             $tagregexp[] = $field->field_key;
         }
         unset($field);
     }
     foreach ($form_ids as $form_id) {
         $fields = FrmField::get_all_for_form($form_id, '', 'include');
         foreach ($fields as $field) {
             $tagregexp[] = $field->id;
             $tagregexp[] = $field->field_key;
         }
     }
     $tagregexp = implode('|', $tagregexp) . '|';
     $tagregexp .= FrmFieldsHelper::allowed_shortcodes();
     if (!ini_get('safe_mode')) {
         // make sure the backtrack limit is as least at the default
         $backtrack_limit = ini_get('pcre.backtrack_limit');
         if ($backtrack_limit < 1000000) {
             ini_set('pcre.backtrack_limit', 1000000);
         }
     }
     preg_match_all("/\\[(if |foreach )?({$tagregexp})\\b(.*?)(?:(\\/))?\\](?:(.+?)\\[\\/\\])?/s", $content, $matches, PREG_PATTERN_ORDER);
     // run conditional and foreach first
     $new_order = $matches[0];
     $move_up = array();
     foreach ($new_order as $short_key => $tag) {
         $conditional = preg_match('/^\\[if/s', $matches[0][$short_key]) ? true : false;
         $foreach = preg_match('/^\\[foreach/s', $matches[0][$short_key]) ? true : false;
         if ($conditional || $foreach) {
             $move_up[$short_key] = $tag;
         }
     }
     if (!empty($move_up)) {
         $matches[0] = $move_up + $matches[0];
     }
     return $matches;
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:51,代码来源:FrmProDisplaysHelper.php

示例14: setup_edit_vars

 function setup_edit_vars($record, $table, $fields = '', $default = false)
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_form, $frm_settings, $frm_sidebar_width;
     $values = array();
     $values['id'] = $record->id;
     foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default_val));
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop($values['description']);
     }
     $values['fields'] = array();
     if ($fields) {
         foreach ($fields as $field) {
             $field->field_options = stripslashes_deep(maybe_unserialize($field->field_options));
             if ($default) {
                 $meta_value = $field->default_value;
             } else {
                 if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) {
                     $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
                 } else {
                     if (isset($record->metas)) {
                         $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
                     } else {
                         $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id);
                     }
                 }
             }
             $field_type = isset($_POST['field_options']['type_' . $field->id]) ? $_POST['field_options']['type_' . $field->id] : $field->type;
             $new_value = isset($_POST['item_meta'][$field->id]) ? $_POST['item_meta'][$field->id] : $meta_value;
             $new_value = maybe_unserialize($new_value);
             if (is_array($new_value)) {
                 $new_value = stripslashes_deep($new_value);
             }
             $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => stripslashes_deep(maybe_unserialize($field->default_value)), 'name' => stripslashes($field->name), 'description' => stripslashes($field->description), 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => stripslashes_deep(maybe_unserialize($field->options)), 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
             /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
                   foreach((array)$field_array['options'] as $opt_key => $opt){
                       if(!is_array($opt))
                           $field_array['options'][$opt_key] = array('label' => $opt);
                       unset($opt);
                       unset($opt_key);
                   }
               }*/
             $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
             foreach ($opt_defaults as $opt => $default_opt) {
                 $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt . '_' . $field->id])) ? $_POST['field_options'][$opt . '_' . $field->id] : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
                 if ($opt == 'blank' and $field_array[$opt] == '') {
                     $field_array[$opt] = __('This field cannot be blank', 'formidable');
                 } else {
                     if ($opt == 'invalid' and $field_array[$opt] == '') {
                         if ($field_type == 'captcha') {
                             $field_array[$opt] = $frm_settings->re_msg;
                         } else {
                             $field_array[$opt] = $field_array['name'] . ' ' . __('is invalid', 'formidable');
                         }
                     }
                 }
             }
             unset($opt_defaults);
             if ($field_array['custom_html'] == '') {
                 $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
             }
             if ($field_array['size'] == '') {
                 $field_array['size'] = $frm_sidebar_width;
             }
             $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
             unset($field);
         }
     }
     if ($table == 'entries') {
         $form = $frm_form->getOne($record->form_id);
     } else {
         if ($table == 'forms') {
             $form = $frm_form->getOne($record->id);
         }
     }
     if ($form) {
         $form->options = maybe_unserialize($form->options);
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 $values[$opt] = FrmAppHelper::get_param($opt, $value);
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $form_defaults['email_to'] = '';
     //options to allow blank answers
     foreach (array('email_to', 'reply_to', 'reply_to_name') as $opt) {
         if (!isset($values[$opt])) {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $form_defaults[$opt];
             unset($form_defaults[$opt]);
             unset($opt);
         }
     }
     //don't allow blank answers
     foreach ($form_defaults as $opt => $default) {
//.........这里部分代码省略.........
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:101,代码来源:FrmAppHelper.php

示例15: serialize

$field_values['options'] = serialize(array('', 'AL', 'AK', 'AS', 'AZ', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'));
$field_values['field_options']['classes'] = 'frm_fourth';
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('text', $form_id));
$field_values['name'] = 'Postal Code';
$field_values['field_order'] = '10';
$field_values['field_options']['classes'] = 'frm_right_fourth';
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('select', $form_id));
$field_values['name'] = 'Country';
$field_values['required'] = 1;
$field_values['field_order'] = '11';
$field_values['field_options']['size'] = 1;
$field_values['options'] = serialize(array('', 'Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Indian Ocean Territory', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Cook Islands', 'Costa Rica', 'Côte d\'Ivoire', 'Croatia (Hrvatska)', 'Cuba', 'Cyprus', 'Czech Republic', 'Congo (DRC)', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Islas Malvinas)', 'Faroe Islands', 'Fiji Islands', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern and Antarctic Lands', 'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hong Kong SAR', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macao SAR', 'Macedonia, Former Yugoslav Republic of', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palestine', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Romania', 'Russia', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia and Montenegro', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe'));
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('radio', $form_id));
$field_values['name'] = 'Employment Desired';
$field_values['required'] = 1;
$field_values['field_order'] = '12';
$field_values['options'] = serialize(array('Full-time', 'Part-time', 'Full- or Part- time'));
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('file', $form_id));
$field_values['name'] = 'Attach Resume';
$field_values['field_order'] = '13';
$field_values['field_options']['attach'] = 1;
$frm_field->create($field_values);
unset($field_values);
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:31,代码来源:frmproapplication.php


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