本文整理汇总了PHP中FrmFormsHelper类的典型用法代码示例。如果您正苦于以下问题:PHP FrmFormsHelper类的具体用法?PHP FrmFormsHelper怎么用?PHP FrmFormsHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrmFormsHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: duplicate
public static function duplicate($old_form_id, $form_id, $copy_keys = false, $blog_id = false)
{
global $frm_duplicate_ids;
$fields = self::getAll(array('fi.form_id' => $old_form_id), 'field_order', '', $blog_id);
foreach ((array) $fields as $field) {
$new_key = $copy_keys ? $field->field_key : '';
if ($copy_keys && substr($field->field_key, -1) == 2) {
$new_key = rtrim($new_key, 2);
}
$values = array();
FrmFieldsHelper::fill_field($values, $field, $form_id, $new_key);
// If this is a repeating section, create new form
if ($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);
}
}
示例2: test_create
/**
* @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);
}
示例3: test_create_form
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);
}
示例4: switch_form_box
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'));
}
示例5: form
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
}
示例6: validate
public static function validate($params, $fields, $form, $title, $description)
{
global $frm_vars;
$frm_settings = FrmAppHelper::get_settings();
if (($_POST && isset($_POST['frm_page_order_' . $form->id]) || FrmProFormsHelper::going_to_prev($form->id)) && !FrmProFormsHelper::saving_draft()) {
$errors = '';
$fields = FrmFieldsHelper::get_form_fields($form->id);
$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
add_filter('frm_continue_to_create', '__return_false');
} else {
if ($form->editable && isset($form->options['single_entry']) && $form->options['single_entry'] && $form->options['single_entry_type'] == 'user') {
$user_ID = get_current_user_id();
if ($user_ID) {
$entry = FrmEntry::getAll(array('it.user_id' => $user_ID, 'it.form_id' => $form->id), '', 1, true);
if ($entry) {
$entry = reset($entry);
}
} else {
$entry = false;
}
if ($entry && !empty($entry) && (!isset($frm_vars['created_entries'][$form->id]) || !isset($frm_vars['created_entries'][$form->id]['entry_id']) || $entry->id != $frm_vars['created_entries'][$form->id]['entry_id'])) {
FrmProEntriesController::show_responses($entry, $fields, $form, $title, $description);
} else {
$record = $frm_vars['created_entries'][$form->id]['entry_id'];
$saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
if (FrmProFormsHelper::saving_draft()) {
$saved_message = isset($form->options['draft_msg']) ? $form->options['draft_msg'] : __('Your draft has been saved.', 'formidable');
}
$saved_message = apply_filters('frm_content', $saved_message, $form, $record ? $record : false);
$message = wpautop(do_shortcode($record ? $saved_message : $frm_settings->failed_msg));
$message = '<div class="frm_message" id="message">' . $message . '</div>';
FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
}
add_filter('frm_continue_to_create', '__return_false');
} else {
if (FrmProFormsHelper::saving_draft()) {
$record = isset($frm_vars['created_entries']) && isset($frm_vars['created_entries'][$form->id]) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
if (!$record) {
return;
}
$saved_message = '';
FrmProFormsHelper::save_draft_msg($saved_message, $form, $record);
$message = FrmFormsHelper::get_success_message(array('message' => $saved_message, 'form' => $form, 'entry_id' => $record, 'class' => 'frm_message'));
FrmProEntriesController::show_responses($record, $fields, $form, $title, $description, $message);
add_filter('frm_continue_to_create', '__return_false');
}
}
}
}
示例7: setup_new_vars
public static function setup_new_vars($fields, $form = '', $reset = false, $args = array())
{
global $frm_vars;
$values = array();
foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
$values[$var] = FrmAppHelper::get_post_param($var, $default);
}
$values['fields'] = array();
if (empty($fields)) {
return apply_filters('frm_setup_new_entry', $values);
}
foreach ((array) $fields as $field) {
$new_value = self::get_field_value_for_new_entry($field, $reset);
$field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id, 'parent_form_id' => isset($args['parent_form_id']) ? $args['parent_form_id'] : $field->form_id);
$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
$opt_defaults['required_indicator'] = '';
$opt_defaults['original_type'] = $field->type;
foreach ($opt_defaults as $opt => $default_opt) {
$field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
unset($opt, $default_opt);
}
unset($opt_defaults);
if ($field_array['custom_html'] == '') {
$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
}
$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
$field_array = array_merge($field->field_options, $field_array);
$values['fields'][] = $field_array;
if (!$form || !isset($form->id)) {
$form = FrmForm::getOne($field->form_id);
}
}
$form->options = maybe_unserialize($form->options);
if (is_array($form->options)) {
foreach ($form->options as $opt => $value) {
$values[$opt] = FrmAppHelper::get_post_param($opt, $value);
unset($opt, $value);
}
}
$form_defaults = FrmFormsHelper::get_default_opts();
$frm_settings = FrmAppHelper::get_settings();
$form_defaults['custom_style'] = $frm_settings->load_style != 'none';
$values = array_merge($form_defaults, $values);
return apply_filters('frm_setup_new_entry', $values);
}
示例8: 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);
}
}
示例9: get_form_style
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();
}
示例10: single_row
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;
}
示例11: _e
_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')) {
?>
示例12: do_action
}
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
示例13: add_default_templates
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);
}
}
}
示例14: _e
_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
示例15: before_table
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&frm_action=new&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
}
}
}