本文整理汇总了PHP中FrmField::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmField::getAll方法的具体用法?PHP FrmField::getAll怎么用?PHP FrmField::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmField
的用法示例。
在下文中一共展示了FrmField::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public static function validate($values, $exclude = false)
{
global $wpdb;
FrmEntry::sanitize_entry_post($values);
$errors = array();
if (!isset($values['form_id']) || !isset($values['item_meta'])) {
$errors['form'] = __('There was a problem with your submission. Please try again.', 'formidable');
return $errors;
}
if (FrmAppHelper::is_admin() && is_user_logged_in() && (!isset($values['frm_submit_entry_' . $values['form_id']]) || !wp_verify_nonce($values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce'))) {
$errors['form'] = __('You do not have permission to do that', 'formidable');
}
if (!isset($values['item_key']) || $values['item_key'] == '') {
$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_items', 'item_key');
}
$where = apply_filters('frm_posted_field_ids', array('fi.form_id' => $values['form_id']));
// Don't get subfields
$where['fr.parent_form_id'] = array(null, 0);
// Don't get excluded fields (like file upload fields in the ajax validation)
if (!empty($exclude)) {
$where['fi.type not'] = $exclude;
}
$posted_fields = FrmField::getAll($where, 'field_order');
// Pass exclude value to validate_field function so it can be used for repeating sections
$args = array('exclude' => $exclude);
foreach ($posted_fields as $posted_field) {
self::validate_field($posted_field, $errors, $values, $args);
unset($posted_field);
}
// check for spam
self::spam_check($exclude, $values, $errors);
$errors = apply_filters('frm_validate_entry', $errors, $values, compact('exclude'));
return $errors;
}
示例2: test_getAll
/**
* @covers FrmField::getAll
*/
function test_getAll()
{
$form_id = $this->factory->form->get_id_by_key($this->contact_form_key);
$fields = FrmField::getAll(array('fi.form_id' => (int) $form_id));
$this->assertNotEmpty($fields);
$this->assertTrue(count($fields) >= 7);
foreach ($fields as $field) {
}
}
示例3: test_getAll
/**
* @covers FrmField::getAll
*/
function test_getAll()
{
$forms = array($this->contact_form_key => 8, $this->all_fields_form_key => 33);
foreach ($forms as $form_key => $expected_count) {
$form_id = $this->factory->form->get_id_by_key($form_key);
$fields = FrmField::getAll(array('fi.form_id' => (int) $form_id));
$this->assertNotEmpty($fields);
$this->assertEquals($expected_count, count($fields), 'An incorrect number of fields are retrieved with FrmField::getAll.');
}
}
示例4: csv
public static function csv($form_id = false, $search = '', $fid = '')
{
FrmAppHelper::permission_check('frm_view_entries');
if (!$form_id) {
$form_id = FrmAppHelper::get_param('form', '', 'get', 'sanitize_text_field');
$search = FrmAppHelper::get_param(isset($_REQUEST['s']) ? 's' : 'search', '', 'get', 'sanitize_text_field');
$fid = FrmAppHelper::get_param('fid', '', 'get', 'sanitize_text_field');
}
if (!ini_get('safe_mode')) {
set_time_limit(0);
//Remove time limit to execute this function
$mem_limit = str_replace('M', '', ini_get('memory_limit'));
if ((int) $mem_limit < 256) {
ini_set('memory_limit', '256M');
}
}
global $wpdb;
$form = FrmForm::getOne($form_id);
$form_id = $form->id;
$where = array('fi.type not' => FrmField::no_save_fields());
$where[] = array('or' => 1, 'fi.form_id' => $form->id, 'fr.parent_form_id' => $form->id);
$csv_fields = apply_filters('frm_csv_field_ids', '', $form_id, array('form' => $form));
if ($csv_fields) {
if (!is_array($csv_fields)) {
$csv_fields = explode(',', $csv_fields);
}
if (!empty($csv_fields)) {
$where['fi.id'] = $csv_fields;
}
}
$form_cols = FrmField::getAll($where, 'field_order');
$item_id = FrmAppHelper::get_param('item_id', false, 'get', 'sanitize_text_field');
if (!empty($item_id)) {
$item_id = explode(',', $item_id);
}
$query = array('form_id' => $form_id);
if ($item_id) {
$query['id'] = $item_id;
}
if (!empty($search) && !$item_id) {
$query = FrmProEntriesHelper::get_search_str($query, $search, $form_id, $fid);
}
/**
* Allows the query to be changed for fetching the entry ids to include in the export
*
* $query is the array of options to be filtered. It includes form_id, and maybe id (array of entry ids),
* and the search query. This should return an array, but it can be handled as a string as well.
*/
$query = apply_filters('frm_csv_where', $query, compact('form_id'));
$entry_ids = FrmDb::get_col($wpdb->prefix . 'frm_items it', $query);
unset($query);
if (empty($entry_ids)) {
esc_html_e('There are no entries for that form.', 'formidable');
} else {
FrmProCSVExportHelper::generate_csv(compact('form', 'entry_ids', 'form_cols'));
}
wp_die();
}
示例5: migrate_to_29
/**
* Switch repeating section forms to published and give them names
*/
private static function migrate_to_29()
{
// Get all section fields
$dividers = FrmField::getAll(array('fi.type' => 'divider'));
// Update the form name and status for repeating sections
foreach ($dividers as $d) {
if (!FrmField::is_repeating_field($d)) {
continue;
}
$form_id = $d->field_options['form_select'];
$new_name = $d->name;
if ($form_id && is_numeric($form_id)) {
FrmForm::update($form_id, array('name' => $new_name, 'status' => 'published'));
}
}
}
示例6: sortable_columns
public static function sortable_columns()
{
$form_id = FrmProAppHelper::get_current_form_id();
$frm_field = new FrmField();
$fields = $frm_field->getAll(array('fi.form_id' => $form_id));
unset($frm_field);
$columns = array($form_id . '_id' => 'id', $form_id . '_created_at' => 'created_at', $form_id . '_updated_at' => 'updated_at', $form_id . '_ip' => 'ip', $form_id . '_item_key' => 'item_key', $form_id . '_is_draft' => 'is_draft');
foreach ($fields as $field) {
if ($field->type != 'checkbox' && (!isset($field->field_options['post_field']) || $field->field_options['post_field'] == '')) {
// Can't sort on checkboxes because they are stored serialized, or post fields
$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
}
}
return $columns;
}
示例7: form
function form($instance)
{
$pages = get_posts(array('post_type' => 'page', 'post_status' => 'publish', 'numberposts' => 999, 'order_by' => 'post_title', 'order' => 'ASC'));
$displays = FrmProDisplay::getAll(array('meta_key' => 'frm_show_count', 'meta_value' => 'dynamic'));
//Defaults
$instance = wp_parse_args((array) $instance, array('title' => false, 'display_id' => false, 'post_id' => false, 'title_id' => false, 'cat_list' => false, 'cat_name' => false, 'cat_count' => false, 'cat_id' => false, 'limit' => false));
if ($instance['display_id']) {
$selected_display = FrmProDisplay::getOne($instance['display_id']);
if ($selected_display) {
$selected_form_id = get_post_meta($selected_display->ID, 'frm_form_id', true);
$title_opts = FrmField::getAll(array('fi.form_id' => (int) $selected_form_id, 'type not' => FrmField::no_save_fields()), 'field_order');
$instance['display_id'] = $selected_display->ID;
}
}
?>
<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('display_id');
?>
"><?php
_e('Use Settings from View', 'formidable');
?>
:</label>
<select name="<?php
echo $this->get_field_name('display_id');
?>
" id="<?php
echo $this->get_field_id('display_id');
?>
" class="widefat frm_list_items_display_id">
<option value=""> </option>
<?php
foreach ($displays as $display) {
echo '<option value="' . esc_attr($display->ID) . '" ' . selected($instance['display_id'], $display->ID, false) . '>' . FrmAppHelper::kses($display->post_title) . '</option>';
}
?>
</select>
</p>
<p class="description"><?php
_e('Views with a "Both (Dynamic)" format will show here.', 'formidable');
?>
</p>
<p><label for="<?php
echo $this->get_field_id('post_id');
?>
"><?php
_e('Page if not specified in View settings', 'formidable');
?>
:</label>
<select name="<?php
echo $this->get_field_name('post_id');
?>
" id="<?php
echo $this->get_field_id('post_id');
?>
" class="widefat">
<option value=""> </option>
<?php
foreach ($pages as $page) {
echo '<option value="' . esc_attr($page->ID) . '" ' . selected($instance['post_id'], $page->ID, false) . '>' . $page->post_title . '</option>';
}
?>
</select>
</p>
<p><label for="<?php
echo $this->get_field_id('title_id');
?>
"><?php
_e('Title Field', 'formidable');
?>
:</label>
<select name="<?php
echo $this->get_field_name('title_id');
?>
" id="<?php
echo $this->get_field_id('title_id');
?>
" class="widefat frm_list_items_title_id">
<option value=""> </option>
<?php
if (isset($title_opts) && $title_opts) {
//.........这里部分代码省略.........
示例8: validate_embedded_form
public static function validate_embedded_form(&$errors, $field, $exclude = array())
{
// Check if this section is conditionally hidden before validating the nested fields
self::validate_no_input_fields($errors, $field);
$subforms = array();
FrmProFieldsHelper::get_subform_ids($subforms, $field);
if (empty($subforms)) {
return;
}
$where = array('fi.form_id' => $subforms);
if (!empty($exclude)) {
$where['fi.type not'] = $exclude;
}
$subfields = FrmField::getAll($where, 'field_order');
unset($where);
foreach ($subfields as $subfield) {
if (isset($_POST['item_meta'][$field->id]) && !empty($_POST['item_meta'][$field->id])) {
foreach ($_POST['item_meta'][$field->id] as $k => $values) {
if (!empty($k) && in_array($k, array('form', 'id'))) {
continue;
}
FrmEntryValidate::validate_field($subfield, $errors, isset($values[$subfield->id]) ? $values[$subfield->id] : '', array('parent_field_id' => $field->id, 'key_pointer' => $k, 'id' => $subfield->id . '-' . $field->id . '-' . $k));
unset($k, $values);
}
} else {
// TODO: do something if nothing was submitted
}
}
}
示例9: _logic_row
function _logic_row()
{
global $frm_ajax_url;
$meta_name = FrmAppHelper::get_param('meta_name');
$form_id = FrmAppHelper::get_param('form_id');
$field_id = FrmAppHelper::get_param('field_id');
$hide_field = '';
$form_fields = FrmField::getAll("fi.form_id = " . $form_id . " and (type in ('select','radio','checkbox','10radio','scale','data') or (type = 'data' and (field_options LIKE '\"data_type\";s:6:\"select\"%' OR field_options LIKE '%\"data_type\";s:5:\"radio\"%' OR field_options LIKE '%\"data_type\";s:8:\"checkbox\"%') )) and fi.id != " . $field_id, " ORDER BY field_order");
$field = FrmField::getOne($field_id);
$field = FrmFieldsHelper::setup_edit_vars($field);
if (!isset($field['hide_field_cond'][$meta_name])) {
$field['hide_field_cond'][$meta_name] = '==';
}
include FRMPRO_VIEWS_PATH . '/frmpro-fields/_logic_row.php';
die;
}
示例10: search_box
public function search_box($text, $input_id)
{
if (!$this->has_items() && !isset($_REQUEST['s'])) {
return;
}
if (isset($this->params['form'])) {
$form = FrmForm::getOne($this->params['form']);
} else {
$form = FrmForm::get_published_forms(array(), 1);
}
if ($form) {
$field_list = FrmField::getAll(array('fi.form_id' => $form->id, 'fi.type not' => FrmField::no_save_fields()), 'field_order');
}
$fid = isset($_REQUEST['fid']) ? esc_attr(stripslashes($_REQUEST['fid'])) : '';
$input_id = $input_id . '-search-input';
$search_str = isset($_REQUEST['s']) ? esc_attr(stripslashes($_REQUEST['s'])) : '';
foreach (array('orderby', 'order') as $get_var) {
if (!empty($_REQUEST[$get_var])) {
echo '<input type="hidden" name="' . esc_attr($get_var) . '" value="' . esc_attr($_REQUEST[$get_var]) . '" />';
}
}
?>
<div class="search-box frm_sidebar">
<label class="screen-reader-text" for="<?php
echo esc_attr($input_id);
?>
"><?php
echo esc_attr($text);
?>
:</label>
<input type="text" id="<?php
echo esc_attr($input_id);
?>
" name="s" value="<?php
echo esc_attr($search_str);
?>
" />
<?php
if (isset($field_list) && !empty($field_list)) {
?>
<select name="fid" class="hide-if-js">
<option value="">— <?php
_e('All Fields', 'formidable');
?>
—</option>
<option value="created_at" <?php
selected($fid, 'created_at');
?>
><?php
_e('Entry creation date', 'formidable');
?>
</option>
<option value="id" <?php
selected($fid, 'id');
?>
><?php
_e('Entry ID', 'formidable');
?>
</option>
<?php
foreach ($field_list as $f) {
?>
<option value="<?php
echo $f->type == 'user_id' ? 'user_id' : $f->id;
?>
" <?php
selected($fid, $f->id);
?>
><?php
echo FrmAppHelper::truncate($f->name, 30);
?>
</option>
<?php
}
?>
</select>
<div class="button dropdown hide-if-no-js">
<a href="#" id="frm-fid-search" class="frm-dropdown-toggle" data-toggle="dropdown"><?php
_e('Search', 'formidable');
?>
<b class="caret"></b></a>
<ul class="frm-dropdown-menu pull-right" id="frm-fid-search-menu" role="menu" aria-labelledby="frm-fid-search">
<li><a href="#" id="fid-">— <?php
_e('All Fields', 'formidable');
?>
—</a></li>
<li><a href="#" id="fid-created_at"><?php
_e('Entry creation date', 'formidable');
?>
</a></li>
<li><a href="#" id="fid-id"><?php
_e('Entry ID', 'formidable');
?>
</a></li>
<?php
foreach ($field_list as $f) {
?>
<li><a href="#" id="fid-<?php
echo $f->type == 'user_id' ? 'user_id' : $f->id;
//.........这里部分代码省略.........
示例11: has_field
public static function has_field($type, $form_id, $single = true)
{
global $wpdb;
$frm_field = new FrmField();
if ($single) {
$included = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_fields WHERE form_id=%d AND type=%s", $form_id, $type));
if ($included) {
$included = $frm_field->getOne($included);
}
} else {
$included = $frm_field->getAll(array('type' => $type, 'fi.form_id' => $form_id));
}
return $included;
}
示例12: import_xml_forms
public static function import_xml_forms($forms, $imported)
{
$frm_form = new FrmForm();
$frm_field = new FrmField();
foreach ($forms as $item) {
$form = array('id' => (int) $item->id, 'form_key' => (string) $item->form_key, 'name' => (string) $item->name, 'description' => (string) $item->description, 'options' => (string) $item->options, 'logged_in' => (int) $item->logged_in, 'is_template' => (int) $item->is_template, 'default_template' => (int) $item->default_template, 'editable' => (int) $item->editable, 'status' => (string) $item->status, 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)));
$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
// if template, allow to edit if form keys match, otherwise, creation date must also match
$edit_query = array('form_key' => $form['form_key'], 'is_template' => $form['is_template']);
if (!$form['is_template']) {
$edit_query['created_at'] = $form['created_at'];
}
$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
$this_form = $frm_form->getAll($edit_query, '', 1);
unset($edit_query);
if (!empty($this_form)) {
$form_id = $this_form->id;
$frm_form->update($form_id, $form);
$imported['updated']['forms']++;
$form_fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order');
$old_fields = array();
foreach ($form_fields as $f) {
$old_fields[$f->id] = $f;
$old_fields[$f->field_key] = $f->id;
unset($f);
}
$form_fields = $old_fields;
unset($old_fields);
} else {
//form does not exist, so create it
if ($form_id = $frm_form->create($form)) {
$imported['imported']['forms']++;
}
}
foreach ($item->field as $field) {
$f = array('id' => (int) $field->id, 'field_key' => (string) $field->field_key, 'name' => (string) $field->name, 'description' => (string) $field->description, 'type' => (string) $field->type, 'default_value' => FrmAppHelper::maybe_json_decode((string) $field->default_value), 'field_order' => (int) $field->field_order, 'form_id' => (int) $form_id, 'required' => (int) $field->required, 'options' => FrmAppHelper::maybe_json_decode((string) $field->options), 'field_options' => FrmAppHelper::maybe_json_decode((string) $field->field_options));
if (is_array($f['default_value']) && in_array($f['type'], array('text', 'email', 'url', 'textarea', 'number', 'phone', 'date', 'time', 'image', 'hidden', 'password', 'tag'))) {
if (count($f['default_value']) === 1) {
$f['default_value'] = '[' . reset($f['default_value']) . ']';
} else {
$f['default_value'] = reset($f['default_value']);
}
}
$f = apply_filters('frm_duplicated_field', $f);
if ($this_form) {
// check for field to edit by field id
if (isset($form_fields[$f['id']])) {
$frm_field->update($f['id'], $f);
$imported['updated']['fields']++;
unset($form_fields[$f['id']]);
//unset old field key
if (isset($form_fields[$f['field_key']])) {
unset($form_fields[$f['field_key']]);
}
} else {
if (isset($form_fields[$f['field_key']])) {
// check for field to edit by field key
unset($f['id']);
$frm_field->update($form_fields[$f['field_key']], $f);
$imported['updated']['fields']++;
unset($form_fields[$form_fields[$f['field_key']]]);
//unset old field id
unset($form_fields[$f['field_key']]);
//unset old field key
} else {
if ($frm_field->create($f)) {
// if no matching field id or key in this form, create the field
$imported['imported']['fields']++;
}
}
}
} else {
if ($frm_field->create($f)) {
$imported['imported']['fields']++;
}
}
unset($field);
}
// Delete any fields attached to this form that were not included in the template
if (isset($form_fields) && !empty($form_fields)) {
foreach ($form_fields as $field) {
if (is_object($field)) {
$frm_field->destroy($field->id);
}
unset($field);
}
unset($form_fields);
}
// Update field ids/keys to new ones
do_action('frm_after_duplicate_form', $form_id, $form);
$imported['forms'][(int) $item->id] = $form_id;
unset($form);
unset($item);
}
unset($frm_form);
unset($frm_field);
return $imported;
}
示例13: repeat_buttons
public static function repeat_buttons($args, $end = false)
{
$args['end_format'] = 'icon';
if (!$end) {
global $wpdb;
// get end field
$query = array('fi.form_id' => $args['parent_field']['form_id'], 'type' => 'end_divider', 'field_order >' => $args['parent_field']['field_order'] + 1);
$end = (array) FrmField::getAll($query, 'field_order', 1);
foreach (array('format', 'add_label', 'remove_label', 'classes') as $o) {
if (isset($end['field_options'][$o])) {
$end[$o] = $end['field_options'][$o];
}
}
}
if ($end) {
$args['add_label'] = $end['add_label'];
$args['remove_label'] = $end['remove_label'];
if (!empty($end['format'])) {
$args['end_format'] = $end['format'];
}
}
$triggers = self::repeat_button_html($args, $end);
return apply_filters('frm_repeat_triggers', $triggers, $end, $args['parent_field'], $args['field_class']);
}
示例14: _posttax_row
public static function _posttax_row()
{
check_ajax_referer('frm_ajax', 'nonce');
if (isset($_POST['field_id'])) {
$field_vars = array('meta_name' => $_POST['meta_name'], 'field_id' => $_POST['field_id'], 'show_exclude' => (int) $_POST['show_exclude'], 'exclude_cat' => (int) $_POST['show_exclude'] ? '-1' : 0);
} else {
$field_vars = array('meta_name' => '', 'field_id' => '', 'show_exclude' => 0, 'exclude_cat' => 0);
}
$tax_meta = (int) $_POST['tax_key'];
$post_type = sanitize_text_field($_POST['post_type']);
$action_key = (int) $_POST['action_key'];
$action_control = FrmFormActionsController::get_form_actions('wppost');
$action_control->_set($action_key);
if ($post_type) {
$taxonomies = get_object_taxonomies($post_type);
}
$values = array();
if (isset($_POST['form_id'])) {
$values['fields'] = FrmField::getAll(array('fi.form_id' => (int) $_POST['form_id'], 'fi.type' => array('checkbox', 'radio', 'select', 'tag', 'data')), 'field_order');
$values['id'] = (int) $_POST['form_id'];
}
$echo = false;
include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-form-actions/_post_taxonomy_row.php';
wp_die();
}
示例15: get_field_options
/**
* Get field options.
*
* @see https://github.com/wp-premium/formidable-paypal/blob/3.02/models/FrmPaymentAction.php#L37-L42
* @param int $form_id
* @return array
*/
private function get_field_options($form_id)
{
$form_fields = FrmField::getAll(array('fi.form_id' => absint($form_id), 'fi.type not' => array('divider', 'end_divider', 'html', 'break', 'captcha', 'rte', 'form')), 'field_order');
return $form_fields;
}