本文整理汇总了PHP中GFExport类的典型用法代码示例。如果您正苦于以下问题:PHP GFExport类的具体用法?PHP GFExport怎么用?PHP GFExport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GFExport类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form_settings_fields
/**
* Add form settings page with schedule export options.
*
* TODO: Add default email address - admin email if empty?
*
* @since 1.0.0
*
*/
public function form_settings_fields($form)
{
if (!GFCommon::current_user_can_any('gravityforms_edit_forms')) {
wp_die('You do not have permission to access this page');
}
//collect the form id from the schedule export settings page url for the current form
$form_id = $_REQUEST['id'];
$form = apply_filters("gform_form_export_page_{$form_id}", apply_filters('gform_form_export_page', $form));
//collect filter settings TODO: these are currently not used.
$filter_settings = GFCommon::get_field_filter_settings($form);
$filter_settings_json = json_encode($filter_settings);
//collect and add the default export fields
$form = GFExport::add_default_export_fields($form);
$form_fields = $form['fields'];
$choices[] = array('label' => 'Select All', 'name' => '', 'default_value' => 1);
//loop through the fields and format all the inputs in to an array to be rendered as checkboxes
foreach ($form_fields as $field) {
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$choices[] = array('label' => GFCommon::get_label($field, $input['id']), 'name' => $input['id'], 'default_value' => 1);
}
} else {
if (!$field->displayOnly) {
$choices[] = array('label' => GFCommon::get_label($field), 'name' => $field->id, 'default_value' => 1);
}
}
}
$inputs = array(array('title' => "Scheduled Entries Export", 'description' => "The settings below will automatically export new entries and send them to the emails below based on the set time frame.", 'fields' => array(array('label' => "Activate the Schedule", 'type' => "checkbox", 'name' => "enabled", 'tooltip' => "Enabling the schedule based on the sets below. This runs off WP Cron.", 'choices' => array(array('label' => "", 'name' => "enabled"))), array('label' => "Time Frame", 'type' => "select", 'name' => "time_frame", 'tooltip' => "Set how frequently it the entries are exported and emailed", 'choices' => array(array('label' => "Hourly", 'value' => "hourly"), array('label' => "Twice Daily", 'value' => "twicedaily"), array('label' => "Daily", 'value' => "daily"), array('label' => "Weekly", 'value' => "weekly"), array('label' => "Monthly - Every 30 Days", 'value' => "monthly"))), array('type' => "text", 'name' => "email", 'label' => "Email Address", 'class' => "medium", 'tooltip' => "Enter a comma separated list of emails you would like to receive the exported entries file."), array('label' => "Form Fields", 'type' => "checkbox", 'name' => "fields", 'tooltip' => "Select the fields you would like to include in the export. Caution: Make sure you are not sending any sensitive information.", 'choices' => $choices))));
return $inputs;
}
示例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();
}
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);
$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: setUp
/** Activate the plugin, mock all the things */
public function setUp()
{
parent::setUp();
/* Activate GravityForms */
require_once WP_PLUGIN_DIR . '/gravityforms/gravityforms.php';
require_once WP_PLUGIN_DIR . '/gravityforms/export.php';
/* Something happened in newer versions, and we can't get the lead cache to initialize
properly, we need to do this manually */
global $_gform_lead_meta;
if ($_gform_lead_meta === null) {
$_gform_lead_meta = array();
}
GFForms::setup();
GFCache::flush();
/* Import some ready-made forms */
$this->assertEquals(GFExport::import_file(dirname(__FILE__) . '/forms.xml'), 2);
/* Add a faster turnaround schedule */
add_filter('cron_schedules', function ($s) {
$s['minute'] = array('interval' => 60, 'display' => 'Minutely');
return $s;
});
/* Get an instance of our plugin */
$this->digest = new GFDigestNotifications();
}
示例4: select_export_form
public static function select_export_form()
{
check_ajax_referer('rg_select_export_form', 'rg_select_export_form');
$form_id = intval($_POST['form_id']);
$form = RGFormsModel::get_form_meta($form_id);
/**
* Filters through the Form Export Page
*
* @param int $form_id The ID of the form to export
* @param int $form The Form Object of the form to export
*/
$form = gf_apply_filters('gform_form_export_page', $form_id, $form);
$filter_settings = GFCommon::get_field_filter_settings($form);
$filter_settings_json = json_encode($filter_settings);
$fields = array();
$form = GFExport::add_default_export_fields($form);
if (is_array($form['fields'])) {
/* @var GF_Field $field */
foreach ($form['fields'] as $field) {
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$fields[] = array($input['id'], GFCommon::get_label($field, $input['id']));
}
} else {
if (!$field->displayOnly) {
$fields[] = array($field->id, GFCommon::get_label($field));
}
}
}
}
$field_json = GFCommon::json_encode($fields);
die("EndSelectExportForm({$field_json}, {$filter_settings_json});");
}
示例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/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;
}
}
}
示例6: maybe_export
public static function maybe_export()
{
if (isset($_POST["export_lead"])) {
check_admin_referer("rg_start_export", "rg_start_export_nonce");
$form_id = $_POST["export_form"];
$form = RGFormsModel::get_form_meta($form_id);
$filename = sanitize_title_with_dashes($form["title"]) . "-" . date("Y-m-d") . ".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);
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 = $_POST["gf_form_id"];
if (empty($selected_forms)) {
echo "<div class='error' style='padding:15px;'>" . __("Please select the forms to be exported", "gravityforms") . "</div>";
return;
}
$forms = RGFormsModel::get_forms_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);
unset($field["pageNumber"]);
if ($inputType == "checkbox") {
unset($field["inputs"]);
} else {
if ($inputType != "address") {
unset($field["addressType"]);
} else {
if ($inputType != "date") {
unset($field["calendarIconType"]);
} else {
if ($field["type"] == $field["inputType"]) {
unset($field["inputType"]);
}
}
}
}
if (in_array($inputType, array("checkbox", "radio", "select")) && !$field["enableChoiceValue"]) {
foreach ($field["choices"] as &$choice) {
unset($choice["value"]);
}
}
}
}
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/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/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/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/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/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));
$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;
}
}
}
示例7: start_export
public static function start_export()
{
require_once GFCommon::get_base_path() . "/export.php";
GFExport::start_export();
}
示例8: select_export_form
public static function select_export_form()
{
check_ajax_referer("rg_select_export_form", "rg_select_export_form");
$form_id = intval($_POST["form_id"]);
$form = RGFormsModel::get_form_meta($form_id);
$fields = array();
$form = GFExport::add_default_export_fields($form);
if (is_array($form["fields"])) {
foreach ($form["fields"] as $field) {
if (is_array(rgar($field, "inputs"))) {
foreach ($field["inputs"] as $input) {
$fields[] = array($input["id"], GFCommon::get_label($field, $input["id"]));
}
} else {
if (!rgar($field, "displayOnly")) {
$fields[] = array($field["id"], GFCommon::get_label($field));
}
}
}
}
$field_json = GFCommon::json_encode($fields);
die("EndSelectExportForm({$field_json});");
}
示例9: 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;
}
}
}
示例10: import_form
/**
* Import Gravity Form XML
* @param string $xml_path Path to form xml file
* @return int | bool Imported form ID or false
*/
function import_form($xml_path = '')
{
do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_path);
if (empty($xml_path) || !class_exists('GFExport') || !file_exists($xml_path)) {
do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_path);
return false;
}
// import form
$forms = '';
$count = GFExport::import_file($xml_path, $forms);
do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count);
do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms);
if ($count != 1 || empty($forms[0]['id'])) {
do_action('gravityview_log_error', '[import_form] Form Import Failed!');
return false;
}
// import success - return form id
return $forms[0];
}
示例11: import
/**
* Import
*
* @since 0.0.15
* @return void
*/
public function import()
{
global $wpdb;
if (class_exists('GFForms')) {
$table_name = $wpdb->prefix . 'rg_form_meta';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
GFForms::setup_database();
}
if (!$this->if_form_exists($this->form_name)) {
$form = GFExport::import_file($this->filepath);
do_action('gform_forms_post_import', $form);
}
}
}
示例12: generateForm
public static function generateForm()
{
if (class_exists('GFAPI')) {
$thankyouPage = get_page_by_path('events/thank-you', OBJECT, 'page');
$form = array('labelPlacement' => 'top_label', 'useCurrentUserAsAuthor' => '1', 'title' => self::$formTitle, 'descriptionPlacement' => 'below', 'button' => array('type' => 'text', 'text' => 'Submit'), 'fields' => array(array('id' => '1', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'First Name'), array('id' => '2', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'Last Name'), array('id' => '3', 'isRequired' => '1', 'size' => 'medium', 'type' => 'email', 'label' => 'Email'), array('id' => '4', 'isRequired' => '1', 'size' => 'medium', 'type' => 'phone', 'phoneFormat' => 'standard', 'label' => 'Phone'), array('id' => '5', 'isRequired' => '1', 'size' => 'medium', 'type' => 'select', 'label' => 'Number Attending', 'choices' => array(array('text' => '1', 'value' => '1'), array('text' => '2', 'value' => '2'), array('text' => '3', 'value' => '3'), array('text' => '4', 'value' => '4'), array('text' => '5', 'value' => '5'), array('text' => '6', 'value' => '6'), array('text' => '7', 'value' => '7'), array('text' => '8', 'value' => '8'))), array('id' => '6', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:post_title}', 'label' => 'Event Name'), array('id' => '7', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:ID}', 'label' => 'Event Post ID'), array('id' => '8', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventStartDate}', 'label' => 'Event Start Date'), array('id' => '9', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventEndDate}', 'label' => 'Event End Date'), array('id' => '10', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventRecurrence}', 'label' => 'Event Recurrence'), array('id' => '11', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventAllDay}', 'label' => 'All Day Event'), array('id' => '90', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Date'), array('id' => '91', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Time')), 'cssClass' => 'contact-form-gfec-form', 'enableHoneypot' => '1', 'confirmations' => array(array('id' => '5316355c6c8c1', 'isDefault' => '1', 'type' => 'page', 'name' => 'Default Confirmation', 'pageId' => $thankyouPage->ID, 'queryString' => 'eventID={post_id:7}')), 'notifications' => array(array('id' => '53163750d13d3', 'to' => '3', 'name' => 'RSVP', 'event' => 'form_submission', 'toType' => 'field', 'subject' => 'Thank You for Registering for (Event Name:5} - {Event Date:6}', 'message' => '{all_fields}', 'from' => '{admin_email}', 'fromName' => get_bloginfo('name'))));
if (RGFormsModel::is_unique_title($form['title'])) {
$form_id = RGFormsModel::insert_form($form['title']);
$form["id"] = $form_id;
GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = GFExport::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = GFExport::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
}
}