Ejemplo n.º 1
0
 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 ($field->type == 'divider' && self::is_option_true($field, 'repeat')) {
             // create the repeatable form
             $repeat_form_values = FrmFormsHelper::setup_new_vars(array('parent_form_id' => $form_id));
             $new_repeat_form_id = FrmForm::create($repeat_form_values);
             // 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * @covers FrmForm::create
  */
 function test_create()
 {
     $values = FrmFormsHelper::setup_new_vars(false);
     $form_id = FrmForm::create($values);
     $this->assertTrue(is_numeric($form_id));
     $this->assertNotEmpty($form_id);
 }
 function test_create_form()
 {
     FrmAppController::install();
     $frm_form = new FrmForm();
     $values = FrmFormsHelper::setup_new_vars(false);
     $id = $frm_form->create($values);
     $this->assertGreaterThan(0, $id);
 }
 public static function switch_form_box()
 {
     global $post_type_object;
     if (!$post_type_object or $post_type_object->name != 'frm_display') {
         return;
     }
     $form_id = isset($_GET['form']) ? $_GET['form'] : '';
     echo FrmFormsHelper::forms_dropdown('form', $form_id, __('View all forms', 'formidable'));
 }
Ejemplo n.º 5
0
    public function form($instance)
    {
        //Defaults
        $instance = wp_parse_args((array) $instance, array('title' => false, 'form' => false, 'description' => false));
        ?>
	<p><label for="<?php 
        echo esc_attr($this->get_field_id('title'));
        ?>
"><?php 
        _e('Title', 'formidable');
        ?>
:</label><br/>
	<input type="text" class="widefat" id="<?php 
        echo esc_attr($this->get_field_id('title'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('title'));
        ?>
" value="<?php 
        echo esc_attr(stripslashes($instance['title']));
        ?>
" /></p>

	<p><label for="<?php 
        echo esc_attr($this->get_field_id('form'));
        ?>
"><?php 
        _e('Form', 'formidable');
        ?>
:</label><br/>
<?php 
        FrmFormsHelper::forms_dropdown($this->get_field_name('form'), $instance['form'], array('blank' => false, 'field_id' => $this->get_field_id('form'), 'class' => 'widefat'));
        ?>
	</p>

	<p><label for="<?php 
        echo esc_attr($this->get_field_id('description'));
        ?>
"><input class="checkbox" type="checkbox" <?php 
        checked($instance['description'], true);
        ?>
 id="<?php 
        echo esc_attr($this->get_field_id('description'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('description'));
        ?>
" value="1" />
	<?php 
        _e('Show Description', 'formidable');
        ?>
</label></p>
<?php 
    }
Ejemplo n.º 6
0
 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');
             }
         }
     }
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 /**
  * 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);
     }
 }
Ejemplo n.º 9
0
 public static function get_form_style($form = 'default')
 {
     $style = FrmFormsHelper::get_form_style($form);
     if (empty($style) || 1 == $style) {
         $style = 'default';
     }
     $frm_style = new FrmStyle($style);
     return $frm_style->get_one();
 }
 public function single_row($item, $style = '')
 {
     // Set up the hover actions for this user
     $actions = array();
     $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
     $this->get_actions($actions, $item, $view_link);
     $action_links = $this->row_actions($actions);
     // Set up the checkbox ( because the user is editable, otherwise its empty )
     $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
     $r = "<tr id='item-action-{$item->id}'{$style}>";
     list($columns, $hidden, , $primary) = $this->get_column_info();
     $action_col = false;
     foreach ($columns as $column_name => $column_display_name) {
         $class = $column_name . ' column-' . $column_name;
         if ($column_name === $primary) {
             $class .= ' column-primary';
         }
         if (in_array($column_name, $hidden)) {
             $class .= ' frm_hidden';
         } else {
             if (!$action_col && !in_array($column_name, array('cb', 'id', 'form_id', 'post_id'))) {
                 $action_col = $column_name;
             }
         }
         $attributes = 'class="' . esc_attr($class) . '"';
         unset($class);
         $attributes .= ' data-colname="' . $column_display_name . '"';
         $col_name = preg_replace('/^(' . $this->params['form'] . '_)/', '', $column_name);
         $this->column_name = $col_name;
         switch ($col_name) {
             case 'cb':
                 $r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
                 break;
             case 'ip':
             case 'id':
             case 'item_key':
                 $val = $item->{$col_name};
                 break;
             case 'name':
             case 'description':
                 $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
                 break;
             case 'created_at':
             case 'updated_at':
                 $date = FrmAppHelper::get_formatted_time($item->{$col_name});
                 $val = '<abbr title="' . esc_attr(FrmAppHelper::get_formatted_time($item->{$col_name}, '', 'g:i:s A')) . '">' . $date . '</abbr>';
                 break;
             case 'is_draft':
                 $val = empty($item->is_draft) ? __('No') : __('Yes');
                 break;
             case 'form_id':
                 $val = FrmFormsHelper::edit_form_link($item->form_id);
                 break;
             case 'post_id':
                 $val = FrmAppHelper::post_edit_link($item->post_id);
                 break;
             case 'user_id':
                 $user = get_userdata($item->user_id);
                 $val = $user->user_login;
                 break;
             default:
                 $val = apply_filters('frm_entries_' . $col_name . '_column', false, compact('item'));
                 if ($val === false) {
                     $this->get_column_value($item, $val);
                 }
                 break;
         }
         if (isset($val)) {
             $r .= "<td {$attributes}>";
             if ($column_name == $action_col) {
                 $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
                 $r .= '<a href="' . esc_url(isset($actions['edit']) ? $edit_link : $view_link) . '" class="row-title" >' . $val . '</a> ';
                 $r .= $action_links;
             } else {
                 $r .= $val;
             }
             $r .= '</td>';
         }
         unset($val);
     }
     $r .= '</tr>';
     return $r;
 }
Ejemplo n.º 11
0
    _e('No Templates Found', 'formidable');
    ?>
</td></tr>
<?php 
} else {
    $alternate = false;
    foreach ($default_templates as $form) {
        $alternate = !$alternate ? 'alternate' : false;
        ?>
    <tr class="<?php 
        echo $alternate;
        ?>
">
        <td class="post-title">
            <a class="row-title" href="<?php 
        echo $url = FrmFormsHelper::get_direct_link($form->form_key, $form);
        ?>
" title="<?php 
        _e('View', 'formidable');
        ?>
 <?php 
        echo esc_attr($form->name);
        ?>
" target="blank"><?php 
        echo $form->name;
        ?>
</a><br/>
            <div class="row-actions">
                <?php 
        if (current_user_can('frm_edit_forms')) {
            ?>
Ejemplo n.º 12
0
    }
    do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
    if (!apply_filters('frm_continue_to_create', true, $form->id)) {
        return;
    }
    $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
    $created = isset($frm_vars['created_entries']) && isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
    $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
    if (!$created || !is_numeric($created) || $conf_method == 'message') {
        $saved_message = apply_filters('frm_content', $saved_message, $form, $created);
        $message = $created && is_numeric($created) ? '<div class="frm_message" id="message">' . wpautop(do_shortcode($saved_message)) . '</div>' : '<div class="frm_error_style">' . $frm_settings->failed_msg . '</div>';
        if (!isset($form->options['show_form']) || $form->options['show_form']) {
            require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
        } else {
            global $frm_vars;
            FrmFormsHelper::form_loaded($form);
            if ($values['custom_style']) {
                $frm_vars['load_css'] = true;
            }
            if ((!isset($frm_vars['css_loaded']) || !$frm_vars['css_loaded']) && $frm_vars['load_css']) {
                echo FrmAppController::footer_js('header');
                $frm_vars['css_loaded'] = true;
            }
            ?>
<div class="frm_forms<?php 
            echo $values['custom_style'] ? ' with_frm_style' : '';
            ?>
" id="frm_form_<?php 
            echo $form->id;
            ?>
_container"><?php 
Ejemplo n.º 13
0
 public static function add_default_templates($path, $default = true, $template = true)
 {
     _deprecated_function(__FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()');
     global $frm_field;
     $path = untrailingslashit(trim($path));
     $templates = glob($path . "/*.php");
     $frm_form = new FrmForm();
     for ($i = count($templates) - 1; $i >= 0; $i--) {
         $filename = str_replace('.php', '', str_replace($path . '/', '', $templates[$i]));
         $template_query = array('form_key' => $filename);
         if ($template) {
             $template_query['is_template'] = 1;
         }
         if ($default) {
             $template_query['default_template'] = 1;
         }
         $form = $frm_form->getAll($template_query, '', 1);
         $values = FrmFormsHelper::setup_new_vars();
         $values['form_key'] = $filename;
         $values['is_template'] = $template;
         $values['status'] = 'published';
         if ($default) {
             $values['default_template'] = 1;
         }
         include $templates[$i];
         //get updated form
         if (isset($form) && $form) {
             $form = $frm_form->getOne($form->id);
         } else {
             $form = $frm_form->getAll($template_query, '', 1);
         }
         if ($form) {
             do_action('frm_after_duplicate_form', $form->id, (array) $form);
         }
     }
 }
Ejemplo n.º 14
0
_e('Update', 'formidable');
?>
" class="button-primary" />
            <?php 
_e('or', 'formidable');
?>
            <a class="button-secondary cancel" href="?page=formidable<?php 
echo $values['is_template'] ? '-templates' : '';
?>
"><?php 
_e('Cancel', 'formidable');
?>
</a>
            <span style="margin-left:8px;">
            <?php 
FrmFormsHelper::forms_dropdown('frm_switcher', '', __('Switch Form', 'formidable'), false, "frmAddNewForm(this.value,'edit')");
?>
            </span>
        </p>
        
        <input type="hidden" name="frm_action" value="update" />
        <input type="hidden" name="action" value="update" />
        <input type="hidden" name="id" value="<?php 
echo $id;
?>
" />
        <?php 
wp_nonce_field('update-options');
?>

        <?php 
Ejemplo n.º 15
0
    function before_table($footer, $form_id = false)
    {
        if ($footer) {
            return;
        }
        if ($_GET['page'] == 'formidable-entries') {
            ?>
            <div class="alignleft actions">
            <?php 
            FrmFormsHelper::forms_dropdown('frm_redirect_to_list', '', __('Switch Form', 'formidable'), false, "frmRedirectToForm(this.value,'list')");
            ?>
            </div>
            <?php 
            if ($form_id) {
                if (current_user_can('frm_create_entries')) {
                    ?>
                <div class="alignleft"><a href="?page=formidable-entries&amp;frm_action=new&amp;form=<?php 
                    echo $form_id;
                    ?>
" class="button-secondary"><?php 
                    _e('Add New Entry to this form', 'formidable');
                    ?>
</a></div>
            <?php 
                }
            }
        } else {
            if ($_GET['page'] == 'formidable-entry-templates' and $form_id) {
                ?>
            <div class="alignleft actions">
            <?php 
                FrmFormsHelper::forms_dropdown('frm_redirect_to_list', '', __('Switch Form', 'formidable'), false, "frmRedirectToDisplay(this.value,'list')");
                ?>
            </div>
        <?php 
            }
        }
    }
Ejemplo n.º 16
0
<div class="frm_forms <?php 
echo FrmFormsHelper::get_form_style_class($values);
?>
" id="frm_form_<?php 
echo esc_attr($form->id);
?>
_container">
<?php 
if (!isset($include_form_tag) || $include_form_tag) {
    ?>
<form enctype="<?php 
    echo esc_attr(apply_filters('frm_form_enctype', 'multipart/form-data', $form));
    ?>
" method="post" class="frm-show-form <?php 
    do_action('frm_form_classes', $form);
    ?>
" id="form_<?php 
    echo esc_attr($form->form_key);
    ?>
" <?php 
    echo $frm_settings->use_html ? '' : 'action=""';
    ?>
>
<?php 
} else {
    ?>
<div id="form_<?php 
    echo esc_attr($form->form_key);
    ?>
" class="frm-show-form <?php 
    do_action('frm_form_classes', $form);
Ejemplo n.º 17
0
</div>

<div class="postbox ">
<h3 class="hndle"><span><?php 
_e('Form and Display Type', 'formidable');
?>
</span></h3>
<div class="inside">
<table class="form-table">
    <tr class="form-field">
        <th valign="top" scope="row"><?php 
_e('Use Entries from Form', 'formidable');
?>
</th>
        <td><?php 
FrmFormsHelper::forms_dropdown('form_id', $values['form_id'], true, false, "frmDisplayFormSelected(this.value,'{$frm_ajax_url}')");
?>
            <span id="entry_select_container">
                <?php 
if (is_numeric($values['form_id'])) {
    _e('Select Entry', 'formidable') . ': ' . FrmEntriesHelper::entries_dropdown($values['form_id'], 'entry_id', $values['entry_id'], true, __('The first one depending on the Order specified below', 'formidable'));
}
?>
            </span>
        </td>
    </tr>
    <tr class="form-field">
        <th valign="top" scope="row"><?php 
_e('Display Format', 'formidable');
?>
</th>
Ejemplo n.º 18
0
    <style>
    #frm_popup_content h3{
        color:#5A5A5A;
        font-family:Georgia,"Times New Roman",Times,serif;
        font-weight:normal;
        font-size:1.6em;
    }
    </style>
    <div class="wrap" id="frm_popup_content">
    <h3><?php 
_e("Select a form to insert", "formidable");
?>
</h3>
    
    <p><?php 
FrmFormsHelper::forms_dropdown('frm_add_form_id');
?>
</p>

    <p><input type="checkbox" id="frm_display_title" /> <label for="frm_display_title"><?php 
_e("Display form title", "formidable");
?>
</label> &nbsp; &nbsp;
        <input type="checkbox" id="frm_display_description" /> <label for="frm_display_description"><?php 
_e("Display form description", "formidable");
?>
</label>
    </p>
    
    <p><input type="button" class="button-primary" value="Insert Form" onclick="frm_insert_form();" /></p>
        
Ejemplo n.º 19
0
                ?>
</td>
        <td><?php 
                echo $form->form_key;
                ?>
</td>
        <td><?php 
                $text = $frm_entry->getRecordCount($form->id);
                $text = sprintf(_n('%1$s Entry', '%1$s Entries', $text, 'formidable'), $text);
                echo current_user_can('frm_view_entries') ? '<a href="' . esc_url(admin_url('admin.php') . '?page=formidable-entries&form=' . $form->id) . '">' . $text . '</a>' : $text;
                unset($text);
                ?>
</td>
        <td>
            <input type="text" style="font-size:10px;width:100%;" readonly="true" onclick="this.select();" onfocus="this.select();" value="<?php 
                echo $target_url = FrmFormsHelper::get_direct_link($form->form_key, $form->prli_link_id);
                ?>
" /><br/><a href="<?php 
                echo $target_url;
                ?>
" target="blank"><?php 
                _e('View Form', 'formidable');
                ?>
</a>
        </td>
        <td><input type="text" style="font-size:10px;width:100%;" readonly="true" onclick="this.select();" onfocus="this.select();" value="[formidable id=<?php 
                echo $form->id;
                ?>
]" /><br/>
            <input type="text" style="font-size:10px;width:100%;" readonly="true" onclick="this.select();" onfocus="this.select();" value="[formidable key=<?php 
                echo $form->form_key;
Ejemplo n.º 20
0
 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) {
         if (!isset($values[$opt]) or $values[$opt] == '') {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $default;
         }
         unset($opt);
         unset($defaut);
     }
     if (!isset($values['custom_style'])) {
         $values['custom_style'] = ($_POST and isset($_POST['options']['custom_style'])) ? $_POST['options']['custom_style'] : $frm_settings->load_style != 'none';
     }
     if (!isset($values['before_html'])) {
         $values['before_html'] = isset($_POST['options']['before_html']) ? $_POST['options']['before_html'] : FrmFormsHelper::get_default_html('before');
     }
     if (!isset($values['after_html'])) {
         $values['after_html'] = isset($_POST['options']['after_html']) ? $_POST['options']['after_html'] : FrmFormsHelper::get_default_html('after');
     }
     if ($table == 'entries') {
         $values = FrmEntriesHelper::setup_edit_vars($values, $record);
     } else {
         if ($table == 'forms') {
             $values = FrmFormsHelper::setup_edit_vars($values, $record);
         }
     }
     return $values;
 }
Ejemplo n.º 21
0
    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);
    }
Ejemplo n.º 22
0
</th>
                        <td>
                            <input type="text" name="csv_del" value="<?php 
        echo esc_attr($csv_del);
        ?>
" />
                        </td>
                    </tr>

                    <tr class="form-field">
                        <th valign="top" scope="row"><?php 
        _e('Import Into Form', 'formidable');
        ?>
</th>
                        <td><?php 
        FrmFormsHelper::forms_dropdown('form_id', $form_id, true, false);
        ?>
</td>
                    </tr>
                    
                </table>
                <?php 
    } else {
        if ($step == 'Two') {
            ?>
                    <input type="hidden" name="step" value="import" />
                    <input type="hidden" name="csv" value="<?php 
            echo $media_id;
            ?>
" />
                    <input type="hidden" name="row" value="<?php 
Ejemplo n.º 23
0
 function __construct($factory = null)
 {
     parent::__construct($factory);
     global $wpdb;
     $this->default_generation_definitions = FrmFormsHelper::setup_new_vars(false);
 }
Ejemplo n.º 24
0
// Add form messages
require FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php';
?>

    <div id="poststuff">

    <div id="post-body" class="metabox-holder columns-2">
    <div id="post-body-content">
    <?php 
// Add form nav
if (!$values['is_template']) {
    FrmAppController::get_form_nav($id, true, 'hide');
}
?>
    <div class="frm_form_builder<?php 
echo FrmFormsHelper::get_form_style_class($form);
?>
">

        <p class="frm_hidden frm-no-margin">
			<input type="button" value="<?php 
esc_attr_e('Update', 'formidable');
?>
" class="frm_submit_<?php 
echo isset($values['ajax_load']) && $values['ajax_load'] ? '' : 'no_';
?>
ajax button-primary" />
            <span class="frm-loading-img"></span>
        </p>

    <form method="post" id="frm_build_form">
Ejemplo n.º 25
0
                    </a>
                </li>
<?php 
    $col = $col == 'one' ? 'two' : 'one';
    unset($c, $d);
}
?>
    	    </ul>
    	</div>
    </div>
    </div>

    <div class="submitbox" id="major-publishing-actions">
        <div id="delete-action">
            <?php 
echo FrmFormsHelper::delete_trash_link($id, $values['status']);
?>
        </div>

        <div id="publishing-action">
            <form method="post" id="frm_js_build_form">
            <span class="spinner"></span>
		    <input type="hidden" id="frm_compact_fields" name="frm_compact_fields" value="" />
    	    <input type="button" value="<?php 
echo esc_attr($button);
?>
" class="frm_submit_form frm_submit_<?php 
echo isset($values['ajax_load']) && $values['ajax_load'] ? '' : 'no_';
?>
ajax button-primary button-large" id="frm_submit_side" />
    	    </form>
Ejemplo n.º 26
0
    function form($instance)
    {
        //Defaults
        $instance = wp_parse_args((array) $instance, array('title' => false, 'form' => false, 'description' => false, 'size' => 20, 'select_width' => false));
        ?>
	<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title', 'formidable');
        ?>
:</label>
	<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo esc_attr(stripslashes($instance['title']));
        ?>
" /></p>
	
	<p><label for="<?php 
        echo $this->get_field_id('form');
        ?>
"><?php 
        _e('Form', 'formidable');
        ?>
:</label>
	    <?php 
        FrmFormsHelper::forms_dropdown($this->get_field_name('form'), $instance['form'], false, $this->get_field_id('form'));
        ?>
	</p>
	
	<p><label for="<?php 
        echo $this->get_field_id('description');
        ?>
"><input class="checkbox" type="checkbox" <?php 
        checked($instance['description'], true);
        ?>
 id="<?php 
        echo $this->get_field_id('description');
        ?>
" name="<?php 
        echo $this->get_field_name('description');
        ?>
" value="1" />
	<?php 
        _e('Show Description', 'formidable');
        ?>
</label></p>
	
	<p><label for="<?php 
        echo $this->get_field_id('select_width');
        ?>
"><input class="checkbox" type="checkbox" <?php 
        checked($instance['select_width'], true);
        ?>
 id="<?php 
        echo $this->get_field_id('select_width');
        ?>
" name="<?php 
        echo $this->get_field_name('select_width');
        ?>
" value="1" />
	<?php 
        _e('Fit Select Boxes into SideBar', 'formidable');
        ?>
</label></p>
	
	<p><label class="checkbox" for="<?php 
        echo $this->get_field_id('size');
        ?>
"><?php 
        _e('Field Size', 'formidable');
        ?>
:</label>
	
	<input type="text" size="3" id="<?php 
        echo $this->get_field_id('size');
        ?>
" name="<?php 
        echo $this->get_field_name('size');
        ?>
" value="<?php 
        echo esc_attr($instance['size']);
        ?>
" /> <span class="howto" style="display:inline;"><?php 
        _e('characters wide', 'formidable');
        ?>
</span></p>
	<p class="description"><?php 
        _e('If your text fields are too big for your sidebar insert a size here.', 'formidable');
        ?>
</p>
<?php 
    }
Ejemplo n.º 27
0
 public static function input_html($field, $echo = true)
 {
     $class = array();
     //$field['type'];
     self::add_input_classes($field, $class);
     $add_html = array();
     self::add_html_size($field, $add_html);
     self::add_html_length($field, $add_html);
     self::add_html_placeholder($field, $add_html, $class);
     $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
     FrmFormsHelper::add_html_attr($class, 'class', $add_html);
     self::add_shortcodes_to_html($field, $add_html);
     $add_html = ' ' . implode(' ', $add_html) . '  ';
     if ($echo) {
         echo $add_html;
     }
     return $add_html;
 }
Ejemplo n.º 28
0
<table class="form_results<?php 
echo $atts['style'] ? FrmFormsHelper::get_form_style_class() : '';
?>
" id="form_results<?php 
echo (int) $atts['form']->id;
?>
" cellspacing="0">
    <thead>
    <tr>
    <?php 
if (in_array('id', $atts['fields'])) {
    ?>
    <th><?php 
    _e('ID', 'formidable');
    ?>
</th>
    <?php 
}
foreach ($atts['form_cols'] as $col) {
    ?>
        <th><?php 
    echo $col->name;
    ?>
</th>
    <?php 
}
if ($atts['edit_link']) {
    ?>
    <th><?php 
    echo $atts['edit_link'];
    ?>
Ejemplo n.º 29
0
<?php

if (!empty($form_id)) {
    ?>
    <h4 class="frm_left_label"><?php 
    _e('Select a form:', 'formidable');
    ?>
</h4>
	<?php 
    FrmFormsHelper::forms_dropdown('frmsc_' . $shortcode . '_' . $form_id);
    ?>
    <div class="frm_box_line"></div>
<?php 
}
if (!empty($opts)) {
    ?>
    <h4><?php 
    _e('Options', 'formidable');
    ?>
</h4>
    <ul>
<?php 
    foreach ($opts as $opt => $val) {
        if (isset($val['type']) && 'text' == $val['type']) {
            ?>
		<li>
			<label class="setting" for="frmsc_<?php 
            echo esc_attr($shortcode . '_' . $opt);
            ?>
">
				<span><?php 
Ejemplo n.º 30
0
                                        echo FrmAppHelper::esc_textarea($field['description']);
                                    }
                                    ?>
</textarea>
</td>
</tr>
<?php 
                                } else {
                                    if ($field['type'] == 'form') {
                                        ?>
<tr><td><?php 
                                        _e('Insert Form', 'formidable');
                                        ?>
</td>
<td><?php 
                                        FrmFormsHelper::forms_dropdown('field_options[form_select_' . $field['id'] . ']', $field['form_select'], array('exclude' => $field['form_id']));
                                        ?>
</td>
</tr>

<?php 
                                    } else {
                                        if ($field['type'] == 'phone') {
                                            ?>
<tr>
<td><label><?php 
                                            _e('Format', 'formidable');
                                            ?>
</label>
<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php 
                                            esc_attr_e('Insert the format you would like to accept. Use a regular expression starting with ^ or an exact format like (999)999-9999.', 'formidable');