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


PHP FrmFormsHelper::get_default_html方法代码示例

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


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

示例1: migrate_to_11

    private function migrate_to_11()
    {
        global $wpdb;
        $forms = FrmDb::get_results($this->forms, array(), 'id, options');
        $sending = __('Sending', 'formidable');
        $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
        $old_default_html = <<<DEFAULT_HTML
<div class="frm_submit">
[if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
<input type="submit" value="[button_label]" [button_action] />
<img class="frm_ajax_loading" src="{$img}" alt="{$sending}" style="visibility:hidden;" />
</div>
DEFAULT_HTML;
        unset($sending, $img);
        $new_default_html = FrmFormsHelper::get_default_html('submit');
        $draft_link = FrmFormsHelper::get_draft_link();
        foreach ($forms as $form) {
            $form->options = maybe_unserialize($form->options);
            if (!isset($form->options['submit_html']) || empty($form->options['submit_html'])) {
                continue;
            }
            if ($form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html) {
                $form->options['submit_html'] = $new_default_html;
                $wpdb->update($this->forms, array('options' => serialize($form->options)), array('id' => $form->id));
            } else {
                if (!strpos($form->options['submit_html'], 'save_draft')) {
                    $form->options['submit_html'] = preg_replace('~\\<\\/div\\>(?!.*\\<\\/div\\>)~', $draft_link . "\r\n</div>", $form->options['submit_html']);
                    $wpdb->update($this->forms, array('options' => serialize($form->options)), array('id' => $form->id));
                }
            }
            unset($form);
        }
        unset($forms);
    }
开发者ID:hugocica,项目名称:locomotiva-2016,代码行数:34,代码来源:FrmDb.php

示例2: fill_form_defaults

 /**
  * Set to POST value or default
  */
 private static function fill_form_defaults($post_values, array &$values)
 {
     $form_defaults = FrmFormsHelper::get_default_opts();
     foreach ($form_defaults as $opt => $default) {
         if (!isset($values[$opt]) || $values[$opt] == '') {
             $values[$opt] = $post_values && isset($post_values['options'][$opt]) ? $post_values['options'][$opt] : $default;
         }
         unset($opt, $defaut);
     }
     if (!isset($values['custom_style'])) {
         $frm_settings = self::get_settings();
         $values['custom_style'] = $post_values && isset($post_values['options']['custom_style']) ? absint($_POST['options']['custom_style']) : $frm_settings->load_style != 'none';
     }
     foreach (array('before', 'after', 'submit') as $h) {
         if (!isset($values[$h . '_html'])) {
             $values[$h . '_html'] = isset($post_values['options'][$h . '_html']) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html($h);
         }
         unset($h);
     }
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:23,代码来源:FrmAppHelper.php

示例3: setup_new_vars

 function setup_new_vars()
 {
     global $frmdb, $frm_settings;
     $values = array();
     foreach (array('name' => __('Untitled Form', 'formidable'), 'description' => '') as $var => $default) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default));
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop($values['description']);
     }
     foreach (array('form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0) as $var => $default) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default));
     }
     $values['form_key'] = ($_POST and isset($_POST['form_key'])) ? $_POST['form_key'] : FrmAppHelper::get_unique_key('', $frmdb->forms, 'form_key');
     $defaults = FrmFormsHelper::get_default_opts();
     foreach ($defaults as $var => $default) {
         $values[$var] = ($_POST and isset($_POST['options'][$var])) ? $_POST['options'][$var] : $default;
     }
     $values['custom_style'] = ($_POST and isset($_POST['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none';
     $values['before_html'] = FrmFormsHelper::get_default_html('before');
     $values['after_html'] = FrmFormsHelper::get_default_html('after');
     return apply_filters('frm_setup_new_form_vars', $values);
 }
开发者ID:moscarar,项目名称:cityhow,代码行数:23,代码来源:FrmFormsHelper.php

示例4: 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

示例5: set_update_options

 /**
  * @return array
  */
 public static function set_update_options($new_values, $values)
 {
     if (!isset($values['options'])) {
         return $new_values;
     }
     $options = array();
     FrmFormsHelper::fill_form_options($options, $values);
     $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
     $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
     $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
     $options['submit_html'] = isset($values['options']['submit_html']) && $values['options']['submit_html'] != '' ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
     $options = apply_filters('frm_form_options_before_update', $options, $values);
     $new_values['options'] = serialize($options);
     return $new_values;
 }
开发者ID:mazykin46,项目名称:portfolio,代码行数:18,代码来源:FrmForm.php

示例6: setup_new_vars

 function setup_new_vars($fields, $form = '', $reset = false)
 {
     global $frm_form, $frm_settings, $frm_sidebar_width;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = stripslashes(FrmAppHelper::get_post_param($var, $default));
     }
     $values['fields'] = array();
     if ($fields) {
         foreach ($fields as $field) {
             $field->field_options = maybe_unserialize($field->field_options);
             $default = $field->default_value;
             if ($reset) {
                 $new_value = $default;
             } else {
                 $new_value = ($_POST and isset($_POST['item_meta'][$field->id]) and $_POST['item_meta'][$field->id] != '') ? $_POST['item_meta'][$field->id] : $default;
             }
             $is_default = $new_value == $default ? true : false;
             $new_value = stripslashes_deep(maybe_unserialize($new_value));
             if (!is_array($new_value)) {
                 $new_value = apply_filters('frm_get_default_value', $new_value, $field);
             }
             $new_value = str_replace('"', '&quot;', $new_value);
             if ($is_default) {
                 $field->default_value = $new_value;
             } else {
                 $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field);
             }
             $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => 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);
             $opt_defaults['required_indicator'] = '';
             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);
                 unset($default_opt);
             }
             unset($opt_defaults);
             if ($field_array['size'] == '') {
                 $field_array['size'] = $frm_sidebar_width;
             }
             if ($field_array['custom_html'] == '') {
                 $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
             }
             $values['fields'][] = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field_array), $field);
             if (!$form or !isset($form->id)) {
                 $form = $frm_form->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);
             }
         }
         if (!isset($values['custom_style'])) {
             $values['custom_style'] = $frm_settings->load_style != 'none';
         }
         if (!isset($values['email_to'])) {
             $values['email_to'] = '';
         }
         if (!isset($values['submit_value'])) {
             $values['submit_value'] = $frm_settings->submit_value;
         }
         if (!isset($values['success_msg'])) {
             $values['success_msg'] = $frm_settings->success_msg;
         }
         if (!isset($values['akismet'])) {
             $values['akismet'] = '';
         }
         if (!isset($values['before_html'])) {
             $values['before_html'] = FrmFormsHelper::get_default_html('before');
         }
         if (!isset($values['after_html'])) {
             $values['after_html'] = FrmFormsHelper::get_default_html('after');
         }
     }
     return $values;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:86,代码来源:FrmEntriesHelper.php

示例7: setup_new_vars

 public static function setup_new_vars($values = array())
 {
     global $wpdb, $frmdb, $frm_settings;
     if (!empty($values)) {
         $post_values = $values;
     } else {
         $values = array();
         $post_values = isset($_POST) ? $_POST : array();
     }
     foreach (array('name' => '', 'description' => '') as $var => $default) {
         if (!isset($values[$var])) {
             $values[$var] = FrmAppHelper::get_param($var, $default);
         }
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop(str_replace('<br>', '<br />', $values['description']));
     }
     foreach (array('form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0) as $var => $default) {
         if (!isset($values[$var])) {
             $values[$var] = FrmAppHelper::get_param($var, $default);
         }
     }
     if (!isset($values['form_key'])) {
         $values['form_key'] = ($post_values and isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_forms', 'form_key');
     }
     $values = self::fill_default_opts($values, false, $post_values);
     $values['custom_style'] = ($post_values and isset($post_values['options']['custom_style'])) ? $post_values['options']['custom_style'] : $frm_settings->load_style != 'none';
     $values['before_html'] = FrmFormsHelper::get_default_html('before');
     $values['after_html'] = FrmFormsHelper::get_default_html('after');
     $values['submit_html'] = FrmFormsHelper::get_default_html('submit');
     return apply_filters('frm_setup_new_form_vars', $values);
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:32,代码来源:FrmFormsHelper.php

示例8: setup_new_vars

 public static function setup_new_vars($fields, $form = '', $reset = false)
 {
     global $frm_settings, $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) {
         $field->field_options = maybe_unserialize($field->field_options);
         $default = $field->default_value;
         $posted_val = false;
         if ($reset) {
             $new_value = $default;
         } else {
             if ($_POST && isset($_POST['item_meta'][$field->id]) && $_POST['item_meta'][$field->id] != '') {
                 $new_value = stripslashes_deep($_POST['item_meta'][$field->id]);
                 $posted_val = true;
             } else {
                 if (isset($field->field_options['clear_on_focus']) && $field->field_options['clear_on_focus']) {
                     $new_value = '';
                 } else {
                     $new_value = $default;
                 }
             }
         }
         $is_default = $new_value == $default ? true : false;
         //If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
         if ($field && ($field->type == 'data' && $field->field_options['data_type'] == 'checkbox' || $field->type == 'checkbox' || $field->type == 'select' && isset($field->field_options['multiple']) && $field->field_options['multiple'] == 1)) {
             $return_array = true;
         } else {
             $return_array = false;
         }
         $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
         if (!is_array($new_value)) {
             if ($is_default) {
                 $new_value = $field->default_value;
             } else {
                 if (!$posted_val) {
                     $new_value = apply_filters('frm_filter_default_value', $new_value, $field);
                 }
             }
             $new_value = str_replace('"', '&quot;', $new_value);
         }
         unset($is_default);
         unset($posted_val);
         $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);
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         $opt_defaults['required_indicator'] = '';
         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);
             unset($default_opt);
         }
         unset($opt_defaults);
         if ($field_array['size'] == '') {
             $field_array['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : '';
         }
         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);
         foreach ((array) $field->field_options as $k => $v) {
             if (!isset($field_array[$k])) {
                 $field_array[$k] = $v;
             }
             unset($k);
             unset($v);
         }
         $values['fields'][] = $field_array;
         if (!$form or !isset($form->id)) {
             $frm_form = new FrmForm();
             $form = $frm_form->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);
         }
     }
     if (!isset($values['custom_style'])) {
         $values['custom_style'] = $frm_settings->load_style != 'none';
     }
     if (!isset($values['email_to'])) {
         $values['email_to'] = '';
     }
     if (!isset($values['submit_value'])) {
         $values['submit_value'] = $frm_settings->submit_value;
     }
     if (!isset($values['success_msg'])) {
         $values['success_msg'] = $frm_settings->success_msg;
     }
     if (!isset($values['akismet'])) {
         $values['akismet'] = '';
     }
     if (!isset($values['before_html'])) {
//.........这里部分代码省略.........
开发者ID:amit0773,项目名称:manaslake,代码行数:101,代码来源:FrmEntriesHelper.php

示例9: update

 function update($id, $values, $create_link = false)
 {
     global $wpdb, $frmdb, $frm_field, $frm_settings;
     if ($create_link or isset($values['options']) or isset($values['item_meta']) or isset($values['field_options'])) {
         $values['status'] = 'published';
     }
     if (isset($values['form_key'])) {
         $values['form_key'] = FrmAppHelper::get_unique_key($values['form_key'], $frmdb->forms, 'form_key', $id);
     }
     $form_fields = array('form_key', 'name', 'description', 'status', 'prli_link_id');
     $new_values = array();
     if (isset($values['options'])) {
         $options = array();
         $defaults = FrmFormsHelper::get_default_opts();
         foreach ($defaults as $var => $default) {
             $options[$var] = isset($values['options'][$var]) ? $values['options'][$var] : $default;
         }
         $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
         $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
         $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
         $options = apply_filters('frm_form_options_before_update', $options, $values);
         $new_values['options'] = serialize($options);
     }
     foreach ($values as $value_key => $value) {
         if (in_array($value_key, $form_fields)) {
             $new_values[$value_key] = $value;
         }
     }
     if (!empty($new_values)) {
         $query_results = $wpdb->update($frmdb->forms, $new_values, array('id' => $id));
         if ($query_results) {
             wp_cache_delete($id, 'frm_form');
         }
     } else {
         $query_results = true;
     }
     $all_fields = $frm_field->getAll(array('fi.form_id' => $id));
     if ($all_fields and (isset($values['options']) or isset($values['item_meta']) or isset($values['field_options']))) {
         if (!isset($values['item_meta'])) {
             $values['item_meta'] = array();
         }
         $existing_keys = array_keys($values['item_meta']);
         foreach ($all_fields as $fid) {
             if (!in_array($fid->id, $existing_keys)) {
                 $values['item_meta'][$fid->id] = '';
             }
         }
         foreach ($values['item_meta'] as $field_id => $default_value) {
             $field = $frm_field->getOne($field_id);
             if (!$field) {
                 continue;
             }
             $field_options = maybe_unserialize($field->field_options);
             if (isset($values['options']) or isset($values['field_options']['custom_html_' . $field_id])) {
                 //updating the settings page
                 if (isset($values['field_options']['custom_html_' . $field_id])) {
                     $field_options['custom_html'] = isset($values['field_options']['custom_html_' . $field_id]) ? $values['field_options']['custom_html_' . $field_id] : (isset($field_options['custom_html']) ? $field_options['custom_html'] : FrmFieldsHelper::get_default_html($field->type));
                     $field_options = apply_filters('frm_update_form_field_options', $field_options, $field, $values);
                     $frm_field->update($field_id, array('field_options' => $field_options));
                 } else {
                     if ($field->type == 'hidden') {
                         $prev_opts = $field_options;
                         $field_options = apply_filters('frm_update_form_field_options', $field_options, $field, $values);
                         if ($prev_opts != $field_options) {
                             $frm_field->update($field_id, array('field_options' => $field_options));
                         }
                         unset($prev_opts);
                     }
                 }
             } else {
                 //updating the form
                 foreach (array('size', 'max', 'label', 'invalid', 'required_indicator', 'blank', 'classes') as $opt) {
                     $field_options[$opt] = isset($values['field_options'][$opt . '_' . $field_id]) ? trim($values['field_options'][$opt . '_' . $field_id]) : '';
                 }
                 $field_options['separate_value'] = isset($values['field_options']['separate_value_' . $field_id]) ? trim($values['field_options']['separate_value_' . $field_id]) : 0;
                 $field_options = apply_filters('frm_update_field_options', $field_options, $field, $values);
                 $default_value = maybe_serialize($values['item_meta'][$field_id]);
                 $field_key = isset($values['field_options']['field_key_' . $field_id]) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
                 $field_type = isset($values['field_options']['type_' . $field_id]) ? $values['field_options']['type_' . $field_id] : $field->type;
                 $field_description = isset($values['field_options']['description_' . $field_id]) ? $values['field_options']['description_' . $field_id] : $field->description;
                 $frm_field->update($field_id, array('field_key' => $field_key, 'type' => $field_type, 'default_value' => $default_value, 'field_options' => $field_options, 'description' => $field_description));
             }
         }
     }
     if (isset($values['form_key']) && class_exists('PrliLink')) {
         $form = $this->getOne($id);
         global $prli_link;
         $prlink = $prli_link->getOne($form->prli_link_id);
         if ($prlink) {
             $prli = array();
             $prli['url'] = FrmFormsHelper::get_direct_link($values['form_key']);
             $prli['slug'] = $prlink->slug;
             $prli['name'] = $prlink->name;
             $prli['param_forwarding'] = $prlink->param_forwarding;
             $prli['param_struct'] = $prlink->param_struct;
             $prli['redirect_type'] = $prlink->redirect_type;
             $prli['description'] = $prlink->description;
             $prli['track_me'] = $prlink->track_me;
             $prli['nofollow'] = $prlink->nofollow;
             $prli['group_id'] = $prlink->group_id;
//.........这里部分代码省略.........
开发者ID:moscarar,项目名称:cityhow,代码行数:101,代码来源:FrmForm.php

示例10: isset

?>
;
$values['options']['akismet'] = '<?php 
echo isset($form->options['akismet']) ? $form->options['akismet'] : '';
?>
';
$values['options']['custom_style'] = <?php 
echo isset($form->options['custom_style']) ? $form->options['custom_style'] : 0;
?>
;
$values['options']['before_html'] = '<?php 
echo addslashes(isset($form->options['before_html']) ? $form->options['before_html'] : FrmFormsHelper::get_default_html('before'));
?>
';
$values['options']['after_html'] = '<?php 
echo addslashes(isset($form->options['after_html']) ? $form->options['after_html'] : FrmFormsHelper::get_default_html('after'));
?>
';
$values['options']['single_entry'] = <?php 
echo isset($form->options['single_entry']) ? $form->options['single_entry'] : 0;
?>
;
<?php 
if (isset($form->options['single_entry'])) {
    ?>
$values['options']['single_entry_type'] = '<?php 
    echo isset($form->options['single_entry_type']) ? $form->options['single_entry_type'] : 'cookie';
    ?>
';<?php 
}
?>
开发者ID:moscarar,项目名称:cityhow,代码行数:31,代码来源:export_template.php

示例11: setup_edit_vars

 public static function setup_edit_vars($record, $table, $fields = '', $default = false, $post_values = array())
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_settings, $frm_vars;
     if (empty($post_values)) {
         $post_values = stripslashes_deep($_POST);
     }
     $values = array('id' => $record->id, 'fields' => array());
     foreach (array('name', 'description') as $var) {
         $default_val = isset($record->{$var}) ? $record->{$var} : '';
         $values[$var] = FrmAppHelper::get_param($var, $default_val);
         unset($var, $default_val);
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop(str_replace('<br>', '<br />', $values['description']));
     }
     foreach ((array) $fields as $field) {
         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']) {
                 if (!isset($field->field_options['custom_field'])) {
                     $field->field_options['custom_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_values['field_options']['type_' . $field->id]) ? $post_values['field_options']['type_' . $field->id] : $field->type;
         $new_value = isset($post_values['item_meta'][$field->id]) ? maybe_unserialize($post_values['item_meta'][$field->id]) : $meta_value;
         $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);
         /*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_values && isset($post_values['field_options'][$opt . '_' . $field->id]) ? maybe_unserialize($post_values['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] = $frm_settings->blank_msg;
             } else {
                 if ($opt == 'invalid' and $field_array[$opt] == '') {
                     if ($field_type == 'captcha') {
                         $field_array[$opt] = $frm_settings->re_msg;
                     } else {
                         $field_array[$opt] = sprintf(__('%s is invalid', 'formidable'), $field_array['name']);
                     }
                 }
             }
         }
         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'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : '';
         }
         $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
         if (!isset($field_array['unique']) or !$field_array['unique']) {
             $field_array['unique_msg'] = '';
         }
         foreach ((array) $field->field_options as $k => $v) {
             if (!isset($field_array[$k])) {
                 $field_array[$k] = $v;
             }
             unset($k);
             unset($v);
         }
         $values['fields'][$field->id] = $field_array;
         unset($field);
     }
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($table == 'entries' ? $record->form_id : $record->id);
     unset($frm_form);
     if ($form) {
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 if (in_array($opt, array('email_to', 'reply_to', 'reply_to_name'))) {
                     $values['notification'][0][$opt] = isset($post_values["notification[0][{$opt}]"]) ? maybe_unserialize($post_values["notification[0][{$opt}]"]) : $value;
                 }
                 $values[$opt] = isset($post_values[$opt]) ? maybe_unserialize($post_values[$opt]) : $value;
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     //set to posted value or default
     foreach ($form_defaults as $opt => $default) {
         if (!isset($values[$opt]) or $values[$opt] == '') {
//.........这里部分代码省略.........
开发者ID:amit0773,项目名称:manaslake,代码行数:101,代码来源:FrmAppHelper.php

示例12: update

 function update($id, $values, $create_link = false)
 {
     global $wpdb, $frm_field, $frm_settings;
     if ($create_link || isset($values['options']) || isset($values['item_meta']) || isset($values['field_options'])) {
         $values['status'] = 'published';
     }
     if (isset($values['form_key'])) {
         $values['form_key'] = FrmAppHelper::get_unique_key($values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id);
     }
     $form_fields = array('form_key', 'name', 'description', 'status', 'prli_link_id');
     $new_values = array();
     if (isset($values['options'])) {
         $options = array();
         $defaults = FrmFormsHelper::get_default_opts();
         foreach ($defaults as $var => $default) {
             if ($var == 'notification' && !defined('WP_IMPORTING')) {
                 $options[$var] = isset($values[$var]) ? $values[$var] : $default;
             } else {
                 $options[$var] = isset($values['options'][$var]) ? $values['options'][$var] : $default;
             }
         }
         $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
         $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
         $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
         $options['submit_html'] = isset($values['options']['submit_html']) && $values['options']['submit_html'] != '' ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
         $options = apply_filters('frm_form_options_before_update', $options, $values);
         $new_values['options'] = serialize($options);
     }
     foreach ($values as $value_key => $value) {
         if (in_array($value_key, $form_fields)) {
             $new_values[$value_key] = $value;
         }
     }
     if (!empty($new_values)) {
         $query_results = $wpdb->update($wpdb->prefix . 'frm_forms', $new_values, array('id' => $id));
         if ($query_results) {
             wp_cache_delete($id, 'frm_form');
         }
     } else {
         $query_results = true;
     }
     $all_fields = $frm_field->getAll(array('fi.form_id' => $id), 'field_order');
     if ($all_fields && (isset($values['options']) || isset($values['item_meta']) || isset($values['field_options']))) {
         if (!isset($values['item_meta'])) {
             $values['item_meta'] = array();
         }
         $existing_keys = array_keys($values['item_meta']);
         foreach ($all_fields as $fid) {
             if (!in_array($fid->id, $existing_keys) && (isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted'])) || isset($values['options'])) {
                 $values['item_meta'][$fid->id] = '';
             }
         }
         foreach ($values['item_meta'] as $field_id => $default_value) {
             $field = $frm_field->getOne($field_id);
             if (!$field) {
                 continue;
             }
             $field_options = maybe_unserialize($field->field_options);
             if (isset($values['options']) || isset($values['field_options']['custom_html_' . $field_id])) {
                 //updating the settings page
                 if (isset($values['field_options']['custom_html_' . $field_id])) {
                     $field_options['custom_html'] = isset($values['field_options']['custom_html_' . $field_id]) ? $values['field_options']['custom_html_' . $field_id] : (isset($field_options['custom_html']) ? $field_options['custom_html'] : FrmFieldsHelper::get_default_html($field->type));
                     $field_options = apply_filters('frm_update_form_field_options', $field_options, $field, $values);
                     $frm_field->update($field_id, array('field_options' => $field_options));
                 } else {
                     if ($field->type == 'hidden' || $field->type == 'user_id') {
                         $prev_opts = $field_options;
                         $field_options = apply_filters('frm_update_form_field_options', $field_options, $field, $values);
                         if ($prev_opts != $field_options) {
                             $frm_field->update($field_id, array('field_options' => $field_options));
                         }
                         unset($prev_opts);
                     }
                 }
             }
             if (!isset($values['options']) && !isset($values['field_options']['custom_html_' . $field_id]) || defined('WP_IMPORTING')) {
                 //updating the form
                 foreach (array('size', 'max', 'label', 'invalid', 'blank', 'classes') as $opt) {
                     $field_options[$opt] = isset($values['field_options'][$opt . '_' . $field_id]) ? trim($values['field_options'][$opt . '_' . $field_id]) : '';
                 }
                 $field_options['required_indicator'] = isset($values['field_options']['required_indicator_' . $field_id]) ? trim($values['field_options']['required_indicator_' . $field_id]) : '*';
                 $field_options['separate_value'] = isset($values['field_options']['separate_value_' . $field_id]) ? trim($values['field_options']['separate_value_' . $field_id]) : 0;
                 $field_options = apply_filters('frm_update_field_options', $field_options, $field, $values);
                 $default_value = maybe_serialize($values['item_meta'][$field_id]);
                 $field_key = isset($values['field_options']['field_key_' . $field_id]) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
                 $required = isset($values['field_options']['required_' . $field_id]) ? $values['field_options']['required_' . $field_id] : false;
                 $field_type = isset($values['field_options']['type_' . $field_id]) ? $values['field_options']['type_' . $field_id] : $field->type;
                 $field_description = isset($values['field_options']['description_' . $field_id]) ? $values['field_options']['description_' . $field_id] : $field->description;
                 $frm_field->update($field_id, array('field_key' => $field_key, 'type' => $field_type, 'default_value' => $default_value, 'field_options' => $field_options, 'description' => $field_description, 'required' => $required));
             }
         }
     }
     do_action('frm_update_form', $id, $values);
     do_action('frm_update_form_' . $id, $values);
     return $query_results;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:96,代码来源:FrmForm.php

示例13: upgrade

    function upgrade($old_db_version = false)
    {
        global $wpdb;
        //$frm_db_version is the version of the database we're moving to
        $frm_db_version = FrmAppHelper::$db_version;
        $old_db_version = (double) $old_db_version;
        if (!$old_db_version) {
            $old_db_version = get_option('frm_db_version');
        }
        if ($frm_db_version != $old_db_version) {
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
            $charset_collate = '';
            if ($wpdb->has_cap('collation')) {
                if (!empty($wpdb->charset)) {
                    $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
                }
                if (!empty($wpdb->collate)) {
                    $charset_collate .= " COLLATE {$wpdb->collate}";
                }
            }
            /* Create/Upgrade Fields Table */
            $sql = "CREATE TABLE {$this->fields} (\n                id int(11) NOT NULL auto_increment,\n                field_key varchar(255) default NULL,\n                name text default NULL,\n                description text default NULL,\n                type text default NULL,\n                default_value longtext default NULL,\n                options longtext default NULL,\n                field_order int(11) default 0,\n                required int(1) default NULL,\n                field_options longtext default NULL,\n                form_id int(11) default NULL,\n                created_at datetime NOT NULL,\n                PRIMARY KEY  (id),\n                KEY form_id (form_id),\n                UNIQUE KEY field_key (field_key)\n              ) {$charset_collate};";
            dbDelta($sql);
            /* Create/Upgrade Forms Table */
            $sql = "CREATE TABLE {$this->forms} (\n                id int(11) NOT NULL auto_increment,\n                form_key varchar(255) default NULL,\n                name varchar(255) default NULL,\n                description text default NULL,\n                parent_form_id int(11) default NULL,\n                logged_in tinyint(1) default NULL,\n                editable tinyint(1) default NULL,\n                is_template tinyint(1) default 0,\n                default_template tinyint(1) default 0,\n                status varchar(255) default NULL,\n                prli_link_id int(11) default NULL,\n                options longtext default NULL,\n                created_at datetime NOT NULL,\n                PRIMARY KEY  (id),\n                UNIQUE KEY form_key (form_key)\n              ) {$charset_collate};";
            dbDelta($sql);
            /* Create/Upgrade Items Table */
            $sql = "CREATE TABLE {$this->entries} (\n                id int(11) NOT NULL auto_increment,\n                item_key varchar(255) default NULL,\n                name varchar(255) default NULL,\n                description text default NULL,\n                ip text default NULL,\n                form_id int(11) default NULL,\n                post_id int(11) default NULL,\n                user_id int(11) default NULL,\n                parent_item_id int(11) default NULL,\n                is_draft tinyint(1) default 0,\n                updated_by int(11) default NULL,\n                created_at datetime NOT NULL,\n                updated_at datetime NOT NULL,\n                PRIMARY KEY  (id),\n                KEY form_id (form_id),\n                KEY post_id (post_id),\n                KEY user_id (user_id),\n                KEY parent_item_id (parent_item_id),\n                UNIQUE KEY item_key (item_key)\n              ) {$charset_collate};";
            dbDelta($sql);
            /* Create/Upgrade Meta Table */
            $sql = "CREATE TABLE {$this->entry_metas} (\n                id int(11) NOT NULL auto_increment,\n                meta_value longtext default NULL,\n                field_id int(11) NOT NULL,\n                item_id int(11) NOT NULL,\n                created_at datetime NOT NULL,\n                PRIMARY KEY  (id),\n                KEY field_id (field_id),\n                KEY item_id (item_id)\n              ) {$charset_collate};";
            dbDelta($sql);
            /**** MIGRATE DATA ****/
            if ($frm_db_version >= 1.03 and $old_db_version < 1.03) {
                global $frm_entry;
                $all_entries = $frm_entry->getAll();
                foreach ($all_entries as $ent) {
                    $opts = maybe_unserialize($ent->description);
                    if (is_array($opts) and in_array($opts['ip'])) {
                        $wpdb->update($this->entries, array('ip' => $opts['ip']), array('id' => $ent->id));
                    }
                }
            }
            if ($frm_db_version >= 4 and $old_db_version < 4) {
                global $frm_entry_meta;
                $user_ids = $frm_entry_meta->getAll("fi.type='user_id'");
                foreach ($user_ids as $user_id) {
                    $wpdb->update($this->entries, array('user_id' => $user_id->meta_value), array('id' => $user_id->item_id));
                }
            }
            if ($frm_db_version >= 6 and $old_db_version < 6) {
                $fields = $wpdb->get_results("SELECT id, field_options FROM {$this->fields} WHERE type not in ('hidden', 'user_id', 'break', 'divider', 'html', 'captcha', 'form')");
                $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 (!isset($field->field_options['custom_html']) || empty($field->field_options['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);
                unset($old_default_html);
                unset($fields);
            }
            if ($frm_db_version >= 11 and $old_db_version < 11) {
                $forms = $wpdb->get_results("SELECT id, options FROM {$this->forms}");
                $sending = __('Sending', 'formidable');
                $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
                $old_default_html = <<<DEFAULT_HTML
<div class="frm_submit">
[if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
<input type="submit" value="[button_label]" [button_action] />
<img class="frm_ajax_loading" src="{$img}" alt="{$sending}" style="visibility:hidden;" />
</div>
DEFAULT_HTML;
                unset($sending);
                unset($img);
                $new_default_html = FrmFormsHelper::get_default_html('submit');
                $draft_link = FrmFormsHelper::get_draft_link();
                foreach ($forms as $form) {
                    $form->options = maybe_unserialize($form->options);
//.........这里部分代码省略.........
开发者ID:amit0773,项目名称:manaslake,代码行数:101,代码来源:FrmDb.php


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