本文整理汇总了PHP中RGFormsModel::get_form_meta_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_form_meta_by_id方法的具体用法?PHP RGFormsModel::get_form_meta_by_id怎么用?PHP RGFormsModel::get_form_meta_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_form_meta_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* __construct function.
*
* @access public
* @return void
*/
public function __construct()
{
//get form
$this->form = RGFormsModel::get_form_meta_by_id($_GET['id']);
$this->ggf_settings = isset($this->form[0]['ggf_settings']) ? $this->form[0]['ggf_settings'] : '';
if (!isset($this->ggf_settings['address_fields']['use']) || $this->ggf_settings['address_fields']['use'] == 0) {
return;
}
add_filter('gform_add_field_buttons', array($this, 'field_groups'), 10, 1);
add_filter('gform_field_type_title', array($this, 'fields_title'), 10, 1);
add_action('gform_field_standard_settings', array($this, 'fields_settings'), 10, 2);
add_filter('gform_tooltips', array($this, 'tooltips'));
add_action("gform_editor_js", array($this, 'js_editor'));
add_action('gform_admin_pre_render', array($this, 'render_form'));
}
示例2: maybe_export
public static function maybe_export()
{
if (isset($_POST['export_lead'])) {
check_admin_referer('rg_start_export', 'rg_start_export_nonce');
//see if any fields chosen
if (empty($_POST['export_field'])) {
GFCommon::add_error_message(__('Please select the fields to be exported', 'gravityforms'));
return;
}
$form_id = $_POST['export_form'];
$form = RGFormsModel::get_form_meta($form_id);
$filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv';
$charset = get_option('blog_charset');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/csv; charset=' . $charset, true);
$buffer_length = ob_get_length();
//length or false if no buffer
if ($buffer_length > 1) {
ob_clean();
}
self::start_export($form);
die;
} else {
if (isset($_POST['export_forms'])) {
check_admin_referer('gf_export_forms', 'gf_export_forms_nonce');
$selected_forms = rgpost('gf_form_id');
if (empty($selected_forms)) {
GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms'));
return;
}
$forms = RGFormsModel::get_form_meta_by_id($selected_forms);
$forms = self::prepare_forms_for_export($forms);
$forms['version'] = GFForms::$version;
$forms_json = json_encode($forms);
$filename = 'gravityforms-export-' . date('Y-m-d') . '.json';
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
echo $forms_json;
die;
}
}
}
示例3: maybe_export
/**
* Process the forms export request.
*/
public static function maybe_export()
{
if (isset($_POST['export_forms'])) {
check_admin_referer('gf_export_forms', 'gf_export_forms_nonce');
$selected_forms = rgpost('gf_form_id');
if (empty($selected_forms)) {
GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms'));
return;
}
$forms = RGFormsModel::get_form_meta_by_id($selected_forms);
$forms = self::prepare_forms_for_export($forms);
$forms['version'] = GFForms::$version;
$forms_json = json_encode($forms);
$filename = 'gravityforms-export-' . date('Y-m-d') . '.json';
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
echo $forms_json;
die;
}
}
示例4: maybe_export
public static function maybe_export()
{
if (isset($_POST['export_lead'])) {
check_admin_referer('rg_start_export', 'rg_start_export_nonce');
//see if any fields chosen
if (empty($_POST['export_field'])) {
GFCommon::add_error_message(__('Please select the fields to be exported', 'gravityforms'));
return;
}
$form_id = $_POST['export_form'];
$form = RGFormsModel::get_form_meta($form_id);
$filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv';
$charset = get_option('blog_charset');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/csv; charset=' . $charset, true);
$buffer_length = ob_get_length();
//length or false if no buffer
if ($buffer_length > 1) {
ob_clean();
}
GFExport::start_export($form);
die;
} else {
if (isset($_POST['export_forms'])) {
check_admin_referer('gf_export_forms', 'gf_export_forms_nonce');
$selected_forms = rgpost('gf_form_id');
if (empty($selected_forms)) {
GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms'));
return;
}
$forms = RGFormsModel::get_form_meta_by_id($selected_forms);
// clean up a bit before exporting
foreach ($forms as &$form) {
foreach ($form['fields'] as &$field) {
$inputType = RGFormsModel::get_input_type($field);
if (isset($field->pageNumber)) {
unset($field->pageNumber);
}
if ($inputType != 'address') {
unset($field->addressType);
}
if ($inputType != 'date') {
unset($field->calendarIconType);
unset($field->dateType);
}
if ($inputType != 'creditcard') {
unset($field->creditCards);
}
if ($field->type == $field->inputType) {
unset($field->inputType);
}
// convert associative array to indexed
if (isset($form['confirmations'])) {
$form['confirmations'] = array_values($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = array_values($form['notifications']);
}
}
/**
* Allows you to filter and modify the Export Form
*
* @param array $form Assign which Gravity Form to change the export form for
*/
$form = gf_apply_filters('gform_export_form', $form['id'], $form);
}
$forms['version'] = GFForms::$version;
$forms_json = json_encode($forms);
$filename = 'gravityforms-export-' . date('Y-m-d') . '.json';
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
echo $forms_json;
die;
}
}
}
示例5: maybe_export
public static function maybe_export()
{
if (isset($_POST["export_lead"])) {
check_admin_referer("rg_start_export", "rg_start_export_nonce");
//see if any fields chosen
if (empty($_POST["export_field"])) {
GFCommon::add_error_message(__('Please select the fields to be exported', 'gravityforms'));
return;
}
$form_id = $_POST["export_form"];
$form = RGFormsModel::get_form_meta($form_id);
$filename = sanitize_title_with_dashes($form["title"]) . "-" . gmdate("Y-m-d", GFCommon::get_local_timestamp(time())) . ".csv";
$charset = get_option('blog_charset');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/plain; charset=' . $charset, true);
$buffer_length = ob_get_length();
//length or false if no buffer
if ($buffer_length > 1) {
ob_clean();
}
GFExport::start_export($form);
die;
} else {
if (isset($_POST["export_forms"])) {
check_admin_referer("gf_export_forms", "gf_export_forms_nonce");
$selected_forms = rgpost("gf_form_id");
if (empty($selected_forms)) {
GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms'));
return;
}
$forms = RGFormsModel::get_form_meta_by_id($selected_forms);
//removing the inputs for checkboxes (choices will be used during the import)
foreach ($forms as &$form) {
foreach ($form["fields"] as &$field) {
$inputType = RGFormsModel::get_input_type($field);
if (isset($field["pageNumber"])) {
unset($field["pageNumber"]);
}
if ($inputType == "checkbox") {
unset($field["inputs"]);
}
if ($inputType != "address") {
unset($field["addressType"]);
}
if ($inputType != "date") {
unset($field["calendarIconType"]);
unset($field["dateType"]);
}
if ($inputType != "creditcard") {
unset($field["creditCards"]);
}
if ($field["type"] == rgar($field, "inputType")) {
unset($field["inputType"]);
}
if (in_array($inputType, array("checkbox", "radio", "select")) && !rgar($field, "enableChoiceValue")) {
foreach ($field["choices"] as &$choice) {
unset($choice["value"]);
}
}
// convert associative array to indexed
if (isset($form['confirmations'])) {
$form['confirmations'] = array_values($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = array_values($form['notifications']);
}
}
}
require_once "xml.php";
$options = array("version" => GFCommon::$version, "forms/form/id" => array("is_hidden" => true), "forms/form/nextFieldId" => array("is_hidden" => true), "forms/form/notification/routing" => array("array_tag" => "routing_item"), "forms/form/useCurrentUserAsAuthor" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/postCategory" => array("is_attribute" => true), "forms/form/postStatus" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/postFormat" => array("is_attribute" => true), "forms/form/labelPlacement" => array("is_attribute" => true), "forms/form/confirmation/type" => array("is_attribute" => true), "forms/form/lastPageButton/type" => array("is_attribute" => true), "forms/form/pagination/type" => array("is_attribute" => true), "forms/form/pagination/style" => array("is_attribute" => true), "forms/form/button/type" => array("is_attribute" => true), "forms/form/button/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/id" => array("is_attribute" => true), "forms/form/fields/field/type" => array("is_attribute" => true), "forms/form/fields/field/inputType" => array("is_attribute" => true), "forms/form/fields/field/displayOnly" => array("is_attribute" => true), "forms/form/fields/field/size" => array("is_attribute" => true), "forms/form/fields/field/isRequired" => array("is_attribute" => true), "forms/form/fields/field/noDuplicates" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/id" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/name" => array("is_attribute" => true), "forms/form/fields/field/formId" => array("is_hidden" => true), "forms/form/fields/field/descriptionPlacement" => array("is_hidden" => true), "forms/form/fields/field/allowsPrepopulate" => array("is_attribute" => true), "forms/form/fields/field/adminOnly" => array("is_attribute" => true), "forms/form/fields/field/enableChoiceValue" => array("is_attribute" => true), "forms/form/fields/field/enableEnhancedUI" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/previousButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/isSelected" => array("is_attribute" => true), "forms/form/fields/field/choices/choice/text" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/value" => array("allow_empty" => true), "forms/form/fields/field/rangeMin" => array("is_attribute" => true), "forms/form/fields/field/rangeMax" => array("is_attribute" => true), "forms/form/fields/field/numberFormat" => array("is_attribute" => true), "forms/form/fields/field/calendarIconType" => array("is_attribute" => true), "forms/form/fields/field/dateFormat" => array("is_attribute" => true), "forms/form/fields/field/dateType" => array("is_attribute" => true), "forms/form/fields/field/nameFormat" => array("is_attribute" => true), "forms/form/fields/field/phoneFormat" => array("is_attribute" => true), "forms/form/fields/field/addressType" => array("is_attribute" => true), "forms/form/fields/field/hideCountry" => array("is_attribute" => true), "forms/form/fields/field/hideAddress2" => array("is_attribute" => true), "forms/form/fields/field/disableQuantity" => array("is_attribute" => true), "forms/form/fields/field/productField" => array("is_attribute" => true), "forms/form/fields/field/enablePrice" => array("is_attribute" => true), "forms/form/fields/field/displayTitle" => array("is_attribute" => true), "forms/form/fields/field/displayCaption" => array("is_attribute" => true), "forms/form/fields/field/displayDescription" => array("is_attribute" => true), "forms/form/fields/field/displayAllCategories" => array("is_attribute" => true), "forms/form/fields/field/postCustomFieldName" => array("is_attribute" => true), "forms/form/confirmations/confirmation/id" => array("is_attribute" => true), "forms/form/confirmations/confirmation/type" => array("is_attribute" => true), "forms/form/confirmations/confirmation/isDefault" => array("is_attribute" => true), "forms/form/confirmations/confirmation/disableAutoformatting" => array("is_attribute" => true), "forms/form/notifications/notification/id" => array("is_attribute" => true));
$serializer = new RGXML($options);
$xml = $serializer->serialize("forms", $forms);
if (!seems_utf8($xml)) {
$value = utf8_encode($xml);
}
$filename = "gravityforms-export-" . date("Y-m-d") . ".xml";
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
echo $xml;
die;
}
}
}
示例6: get_meta_all_fields
function get_meta_all_fields($id)
{
$fledarr = array();
$frmarr = RGFormsModel::get_form_meta_by_id($id);
/*Changed from get_forms_by_id as noted by Redpik https://wordpress.org/support/profile/redpik*/
$fldobj = $frmarr[0]['fields'];
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($fldobj));
$i = 0;
$arrfor = array();
$valarr = array();
$currid = 0;
foreach ($iterator as $key => $value) {
if ($currid != $i && $i != 0) {
$arrfor['value'] = implode(",", $valarr);
$fledarr[$i - 1] = $arrfor;
$arrfor = array();
$valarr = array();
$arrfor['value'] = '';
$currid += 1;
}
if ($key == 'id') {
$arrfor[$key] = $value;
}
if ($key == 'label') {
$arrfor[$key] = $value;
}
if ($key == 'type') {
$arrfor[$key] = $value;
$i++;
}
if ($key == 'value') {
array_push($valarr, $value);
}
}
return $fledarr;
}
示例7: add_user_location
/**
* Update users location using "User registration" gravity forms add-on
*/
function add_user_location($user_id, $config, $entry, $user_pass)
{
//get form details
$form = RGFormsModel::get_form_meta_by_id($config['form_id']);
$form = $form[0];
//get options
$ggfSettings = $form['ggf_settings'];
//get GEO user registration fields
$ggfURSettings = $config['meta']['ggf_settings'];
if (!isset($ggfSettings['address_fields']['use']) || $ggfSettings['address_fields']['use'] == 0) {
return;
}
//when single address field
if (isset($ggfSettings['address_fields']['use']) && $ggfSettings['address_fields']['use'] == 1) {
//find the address field and get its value
foreach ($form['fields'] as $field) {
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'address') {
$address = $entry[$field['id']];
}
}
//cehck if fields avaialbe with form posting. This means that using is being activated automatically
//on form subbmittion. Otherwise, if activated manually we need to get the address fields
//from the entry, geocode it and do the rest
if (isset($_POST['ggf_field_location']) && !empty($_POST['ggf_field_location'])) {
$ggfLocation = $_POST['ggf_field_location'];
} else {
include_once GGF_PATH . '/includes/ggf-geocoder.php';
$ggfLocation = ggf_geocoder($address, false);
}
//get location information into array
$org_location['street'] = $ggfLocation['street'];
$org_location['apt'] = isset($ggfLocation['apt']) && !empty($ggfLocation['apt']) ? $ggfLocation['apt'] : '';
$org_location['city'] = $ggfLocation['city'];
$org_location['state'] = $ggfLocation['state'];
$org_location['zipcode'] = $ggfLocation['zipcode'];
$org_location['country'] = $ggfLocation['country'];
$ggfLocation['org_location'] = $org_location;
$ggfLocation['address'] = $address;
} else {
foreach ($form['fields'] as $field) {
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'street') {
$org_location['street'] = $entry[$field['id']];
}
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'apt') {
$org_location['apt'] = $entry[$field['id']];
}
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'city') {
$org_location['city'] = $entry[$field['id']];
}
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'state') {
$org_location['state'] = $entry[$field['id']];
}
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'zipcode') {
$org_location['zipcode'] = $entry[$field['id']];
}
if (isset($field['ggf_fields']) && $field['ggf_fields'] == 'country') {
$org_location['country'] = $entry[$field['id']];
}
}
//cehck if fields avaialbe with form posting. This means that using is being activated automatically
//on form subbmittion. Otherwise, if activated manually we need to get the address fields
//from the entry, geocode it and do the rest
if (isset($_POST['ggf_field_location']) && !empty($_POST['ggf_field_location'])) {
$ggfLocation = $_POST['ggf_field_location'];
} else {
include_once GGF_PATH . '/includes/ggf-geocoder.php';
$ggfLocation = ggf_geocoder(implode(' ', $org_location), false);
}
$ggfLocation['org_location'] = $org_location;
$ggfLocation['address'] = implode(' ', $org_location);
}
$user_meta_fields = isset($ggfURSettings['address_fields']['user_meta_fields']) && !empty($ggfURSettings['address_fields']['user_meta_fields']) ? $ggfURSettings['address_fields']['user_meta_fields'] : array();
//save location to user meta
foreach ($user_meta_fields as $key => $value) {
if ($key == 'street') {
if (isset($ggfLocation['org_location']['street']) && !empty($ggfLocation['org_location']['street'])) {
update_user_meta($user_id, $value, $ggfLocation['org_location']['street']);
} else {
update_user_meta($user_id, $value, $ggfLocation['street']);
}
} elseif ($key == 'apt') {
if (isset($ggfLocation['org_location']['apt']) && !empty($ggfLocation['org_location']['apt'])) {
update_user_meta($user_id, $value, $ggfLocation['org_location']['apt']);
}
} elseif ($key == 'city') {
if (isset($ggfLocation['org_location']['city']) && !empty($ggfLocation['org_location']['city'])) {
update_user_meta($user_id, $value, $ggfLocation['org_location']['city']);
} else {
update_user_meta($user_id, $value, $ggfLocation['city']);
}
} elseif ($key == 'zipcode') {
if (isset($ggfLocation['org_location']['zipcode']) && !empty($ggfLocation['org_location']['zipcode'])) {
update_user_meta($user_id, $value, $ggfLocation['org_location']['zipcode']);
} else {
update_user_meta($user_id, $value, $ggfLocation['zipcode']);
}
} else {
//.........这里部分代码省略.........