本文整理汇总了PHP中FrmForm类的典型用法代码示例。如果您正苦于以下问题:PHP FrmForm类的具体用法?PHP FrmForm怎么用?PHP FrmForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrmForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare_items
function prepare_items()
{
global $wpdb, $per_page, $frm_settings;
$paged = $this->get_pagenum();
$default_orderby = 'name';
$default_order = 'ASC';
$orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : $default_orderby;
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : $default_order;
$page = $this->get_pagenum();
$default_count = empty($this->page_name) ? 20 : 10;
$per_page = $this->get_items_per_page('formidable_page_formidable' . str_replace('-', '_', $this->page_name) . '_per_page', $default_count);
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : ($page - 1) * $per_page;
$s = isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '';
$fid = isset($_REQUEST['fid']) ? $_REQUEST['fid'] : '';
if ($s != '') {
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
$search_terms = array_map('trim', $matches[0]);
}
$s_query = " (status is NULL OR status = '' OR status = 'published') AND default_template=0 AND is_template = " . (int) $this->params['template'];
if ($s != '') {
foreach ((array) $search_terms as $term) {
if (!empty($s_query)) {
$s_query .= " AND";
}
$term = FrmAppHelper::esc_like($term);
$s_query .= $wpdb->prepare(" (name like %s OR description like %s OR created_at like %s)", '%' . $term . '%', '%' . $term . '%', '%' . $term . '%');
unset($term);
}
}
$frm_form = new FrmForm();
$this->items = $frm_form->getAll($s_query, " ORDER BY {$orderby} {$order}", " LIMIT {$start}, {$per_page}", true, false);
$total_items = FrmAppHelper::getRecordCount($s_query, $this->table_name);
$this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
}
示例2: duplicate
function duplicate($id, $template = false, $copy_keys = false, $blog_id = false)
{
global $wpdb;
$frm_form = new FrmForm();
$values = $frm_form->getOne($id, $blog_id);
if (!$values) {
return false;
}
$new_key = $copy_keys ? $values->form_key : '';
$new_values = array('form_key' => FrmAppHelper::get_unique_key($new_key, $wpdb->prefix . 'frm_forms', 'form_key'), 'name' => $values->name, 'description' => $values->description, 'status' => $template ? '' : 'draft', 'logged_in' => $values->logged_in ? $values->logged_in : 0, 'editable' => $values->editable ? $values->editable : 0, 'created_at' => current_time('mysql', 1), 'is_template' => $template ? 1 : 0);
if ($blog_id) {
$new_values['status'] = 'published';
$new_options = maybe_unserialize($values->options);
$new_options['email_to'] = get_option('admin_email');
$new_options['copy'] = false;
$new_values['options'] = $new_options;
} else {
$new_values['options'] = $values->options;
}
if (is_array($new_values['options'])) {
$new_values['options'] = serialize($new_values['options']);
}
$query_results = $wpdb->insert($wpdb->prefix . 'frm_forms', $new_values);
if ($query_results) {
global $frm_field;
$form_id = $wpdb->insert_id;
$frm_field->duplicate($id, $form_id, $copy_keys, $blog_id);
// update form settings after fields are created
do_action('frm_after_duplicate_form', $form_id, $new_values);
return $form_id;
} else {
return false;
}
}
示例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: get_forms
private function get_forms()
{
$forms = array();
$formidable = new FrmForm();
foreach ($formidable->get_published_forms() as $form) {
$forms[$form->name] = $form->id;
}
return $forms;
}
示例5: entry_created
function entry_created($entry_id, $form_id)
{
if (apply_filters('frm_stop_standard_email', false, $entry_id)) {
return;
}
global $frm_entry, $frm_entry_meta;
$entry = $frm_entry->getOne($entry_id, true);
$frm_form = new FrmForm();
$form = $frm_form->getOne($form_id);
$values = $frm_entry_meta->getAll("it.item_id = {$entry_id}", " ORDER BY fi.field_order");
if (isset($form->options['notification'])) {
$notification = reset($form->options['notification']);
} else {
$notification = $form->options;
}
// Set the from and to email names and addresses
$to_email = $notification['email_to'];
if (empty($to_email)) {
$to_email = '[admin_email]';
}
$to_emails = explode(',', $to_email);
$reply_to = $reply_to_name = '';
foreach ($values as $value) {
$val = apply_filters('frm_email_value', maybe_unserialize($value->meta_value), $value, $entry);
if (is_array($val)) {
$val = implode(', ', $val);
}
if (isset($notification['reply_to']) and (int) $notification['reply_to'] == $value->field_id and is_email($val)) {
$reply_to = $val;
}
if (isset($notification['reply_to_name']) and (int) $notification['reply_to_name'] == $value->field_id) {
$reply_to_name = $val;
}
}
if (empty($reply_to) && $notification['reply_to'] == 'custom') {
$reply_to = $notification['cust_reply_to'];
}
if (empty($reply_to_name) && $notification['reply_to_name'] == 'custom') {
$reply_to_name = $notification['cust_reply_to_name'];
}
// Set the email message
$plain_text = isset($notification['plain_text']) && $notification['plain_text'] ? true : false;
$mail_body = isset($notification['email_message']) ? $notification['email_message'] : '';
$mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
// Set the subject
$subject = isset($notification['email_subject']) ? $notification['email_subject'] : '';
if (empty($subject)) {
$frm_blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$subject = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, $frm_blogname);
}
// Send the emails now
foreach ((array) $to_emails as $to_email) {
$this->send_notification_email(trim($to_email), $subject, $mail_body, $reply_to, $reply_to_name, $plain_text);
}
}
示例6: form
public static function form($errors = array(), $message = '')
{
//wp_enqueue_script('jquery-chosen');
//wp_enqueue_style('formidable');
$frm_form = new FrmForm();
$forms = $frm_form->getAll("status is NULL OR status = '' OR status = 'published'", ' ORDER BY name');
unset($frm_form);
$export_types = apply_filters('frm_xml_export_types', array('forms' => __('Forms', 'formidable')));
$export_format = apply_filters('frm_export_formats', array('xml' => array('name' => 'XML', 'support' => 'forms', 'count' => 'multiple')));
global $frmpro_settings;
$csv_format = $frmpro_settings ? $frmpro_settings->csv_format : 'UTF-8';
include FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php';
}
示例7: _setup_test_update_values
function _setup_test_update_values($entry)
{
$form = FrmForm::getOne($entry->form_id);
$this->set_current_user_to_1();
$values = array('form_id' => $entry->form_id, 'frm_hide_fields_' . $entry->form_id => '', 'frm_helers_' . $entry->form_id => '', 'form_key' => $form->form_key, 'item_meta' => $entry->metas, 'frm_submit_entry_' . $entry->form_id => wp_create_nonce('frm_submit_entry_' . $entry->form_id), '_wp_http_referer' => '/features/create-a-post-no-categories/?frm_action=edit&entry=' . $entry->id, 'id' => $entry->id, 'item_key' => $entry->item_key, 'item_name' => $entry->name, 'frm_user_id' => $entry->user_id, 'frm_skip_cookie' => 1);
return $values;
}
示例8: show
public static function show()
{
FrmAppHelper::permission_check('frm_view_reports');
remove_action('frm_form_action_reports', 'FrmStatisticsController::list_reports');
add_filter('frm_form_stop_action_reports', '__return_true');
global $wpdb;
$form = false;
if (isset($_REQUEST['form'])) {
$form = FrmForm::getOne($_REQUEST['form']);
}
if (!$form) {
require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/select.php';
return;
}
$exclude_types = FrmField::no_save_fields();
$exclude_types = array_merge($exclude_types, array('rte', 'textarea', 'file', 'grid', 'signature', 'form', 'table'));
$fields = FrmField::getAll(array('fi.form_id' => (int) $form->id, 'fi.type not' => $exclude_types), 'field_order');
$js = '';
$data = array();
$colors = '#21759B,#EF8C08,#C6C6C6';
$data['time'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent'));
$data['month'] = self::get_daily_entries($form, array('is3d' => true, 'colors' => $colors, 'bg_color' => 'transparent', 'width' => '100%'), 'MONTH');
foreach ($fields as $field) {
$this_data = self::graph_shortcode(array('id' => $field->id, 'field' => $field, 'is3d' => true, 'min' => 0, 'colors' => $colors, 'width' => 650, 'bg_color' => 'transparent'));
if (strpos($this_data, 'frm_no_data_graph') === false) {
$data[$field->id] = $this_data;
}
unset($field, $this_data);
}
$entries = FrmDb::get_col($wpdb->prefix . 'frm_items', array('form_id' => $form->id), 'created_at');
// trigger the scripts to load
global $frm_vars;
$frm_vars['forms_loaded'][] = true;
include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-statistics/show.php';
}
示例9: setup_edit_vars
public static function setup_edit_vars($record, $doing_ajax = false)
{
$values = array('id' => $record->id, 'form_id' => $record->form_id);
$defaults = array('name' => $record->name, 'description' => $record->description, 'field_key' => $record->field_key, 'type' => $record->type, 'default_value' => $record->default_value, 'field_order' => $record->field_order, 'required' => $record->required);
if ($doing_ajax) {
$values = $values + $defaults;
$values['form_name'] = '';
} else {
foreach ($defaults as $var => $default) {
$values[$var] = FrmAppHelper::get_param($var, $default, 'get', 'htmlspecialchars');
unset($var, $default);
}
$values['form_name'] = $record->form_id ? FrmForm::getName($record->form_id) : '';
}
unset($defaults);
$values['options'] = $record->options;
$values['field_options'] = $record->field_options;
$defaults = self::get_default_field_opts($values['type'], $record, true);
if ($values['type'] == 'captcha') {
$frm_settings = FrmAppHelper::get_settings();
$defaults['invalid'] = $frm_settings->re_msg;
}
foreach ($defaults as $opt => $default) {
$values[$opt] = isset($record->field_options[$opt]) ? $record->field_options[$opt] : $default;
unset($opt, $default);
}
$values['custom_html'] = isset($record->field_options['custom_html']) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
return apply_filters('frm_setup_edit_field_vars', $values, array('doing_ajax' => $doing_ajax));
}
示例10: add_form_nav
public static function add_form_nav($views)
{
if (!FrmProDisplaysHelper::is_edit_view_page()) {
return $views;
}
$form = isset($_REQUEST['form']) && is_numeric($_REQUEST['form']) ? $_REQUEST['form'] : false;
if (!$form) {
return $views;
}
$form = FrmForm::getOne($form);
if (!$form) {
return $views;
}
echo '<div id="poststuff">';
echo '<div id="post-body" class="metabox-holder columns-2">';
echo '<div id="post-body-content">';
FrmAppController::get_form_nav($form, true, 'hide');
echo '</div>';
echo '<div class="clear"></div>';
echo '</div>';
echo '<div id="titlediv"><input id="title" type="text" value="' . esc_attr($form->name == '' ? __('(no title)') : $form->name) . '" readonly="readonly" disabled="disabled" /></div>';
echo '</div>';
echo '<style type="text/css">p.search-box{margin-top:-91px;}</style>';
return $views;
}
示例11: user_can_edit_check
function user_can_edit_check($entry, $form)
{
global $user_ID;
if (!$user_ID) {
return false;
}
if (is_numeric($form)) {
$form = FrmForm::getOne($form);
}
$form->options = maybe_unserialize($form->options);
//if editable and user can edit someone elses entry
if ($form->editable and isset($form->options['open_editable']) and $form->options['open_editable'] and isset($form->options['open_editable_role']) and FrmAppHelper::user_has_permission($form->options['open_editable_role'])) {
return true;
}
if (is_object($entry)) {
if ($entry->user_id == $user_ID) {
return true;
} else {
return false;
}
}
$where = "user_id='{$user_ID}' and fr.id='{$form->id}'";
if ($entry and !empty($entry)) {
if (is_numeric($entry)) {
$where .= ' and it.id=' . $entry;
} else {
$where .= " and item_key='" . $entry . "'";
}
}
return FrmEntry::getAll($where, '', ' LIMIT 1', true);
}
示例12: _check_form_select
/**
* @covers FrmXMLHelper::track_repeating_fields
* @covers FrmXMLHelper::update_repeat_field_options
*/
public function _check_form_select($f, $expected_form_key)
{
$this->assertNotEmpty($f->field_options['form_select'], 'Imported repeating section has a blank form_select.');
// Check if the form_select setting matches the correct form
$nested_form = FrmForm::getOne($f->field_options['form_select']);
$this->assertNotEmpty($nested_form, 'The form_select in an imported repeating section is not updating correctly.');
$this->assertEquals($expected_form_key, $nested_form->form_key, 'The form_select is not updating properly when a repeating section is imported.');
}
示例13: get_form_nav
public static function get_form_nav($id, $show_nav = false)
{
global $pagenow, $frm_vars;
$show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
if (!$show_nav) {
return;
}
$current_page = isset($_GET['page']) ? $_GET['page'] : (isset($_GET['post_type']) ? $_GET['post_type'] : 'None');
if ($id and is_numeric($id)) {
$frm_form = new FrmForm();
$form = $frm_form->getOne($id);
unset($frm_form);
} else {
$form = false;
}
include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
}
示例14: import_xml
function import_xml()
{
// install test data in older format
add_filter('frm_default_templates_files', 'FrmUnitTest::install_data');
FrmXMLController::add_default_templates();
$form = FrmForm::getOne('contact-db12');
$this->assertEquals($form->form_key, 'contact-db12');
}
示例15: _logic_row
public static function _logic_row()
{
check_ajax_referer('frm_ajax', 'nonce');
$meta_name = FrmAppHelper::get_param('meta_name', '', 'get', 'sanitize_title');
$form_id = FrmAppHelper::get_param('form_id', '', 'get', 'absint');
$key = FrmAppHelper::get_param('email_id', '', 'get', 'sanitize_title');
$type = FrmAppHelper::get_param('type', '', 'get', 'sanitize_title');
$form = FrmForm::getOne($form_id);
FrmProFormsController::include_logic_row(array('form_id' => $form->id, 'form' => $form, 'meta_name' => $meta_name, 'condition' => array('hide_field_cond' => '==', 'hide_field' => ''), 'key' => $key, 'name' => 'frm_' . $type . '_action[' . $key . '][post_content][conditions][' . $meta_name . ']'));
wp_die();
}