本文整理汇总了PHP中GFCommon::gf_global方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::gf_global方法的具体用法?PHP GFCommon::gf_global怎么用?PHP GFCommon::gf_global使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::gf_global方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: results_page
public function results_page($form_id, $page_title, $gf_page, $gf_view)
{
if (empty($form_id)) {
$forms = RGFormsModel::get_forms();
if (!empty($forms)) {
$form_id = $forms[0]->id;
}
}
$form = GFFormsModel::get_form_meta($form_id);
$form = gf_apply_filters(array('gform_form_pre_results', $form_id), $form);
// set up filter vars
$start_date = rgget('start');
$end_date = rgget('end');
$all_fields = $form['fields'];
$filter_settings = GFCommon::get_field_filter_settings($form);
$filter_settings = apply_filters('gform_filters_pre_results', $filter_settings, $form);
$filter_settings = array_values($filter_settings);
// reset the numeric keys in case some filters have been unset
$filter_fields = rgget('f');
$filter_operators = rgget('o');
$filter_values = rgget('v');
$filters = array();
$init_vars = array();
if (!empty($filter_fields)) {
$init_vars['mode'] = rgget('mode');
foreach ($filter_fields as $i => $filter_field) {
$filters[$i]['field'] = $filter_field;
$filters[$i]['operator'] = $filter_operators[$i];
$filters[$i]['value'] = $filter_values[$i];
}
$init_vars['filters'] = $filters;
}
?>
<script type="text/javascript">
var gresultsFields = <?php
echo json_encode($all_fields);
?>
;
var gresultsFilterSettings = <?php
echo json_encode($filter_settings);
?>
;
var gresultsInitVars = <?php
echo json_encode($init_vars);
?>
;
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
</script>
<link rel="stylesheet"
href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css?ver=<?php
echo GFCommon::$version;
?>
"
type="text/css"/>
<div class="wrap gforms_edit_form <?php
echo GFCommon::get_browser_class();
?>
">
<h2 class="gf_admin_page_title">
<span><?php
echo empty($form_id) ? $page_title : $page_title . ' : ' . esc_html($form['title']);
?>
</span><span
class="gf_admin_page_subtitle"><span
class="gf_admin_page_formid">ID: <?php
echo $form['id'];
?>
</span><span
class="gf_admin_page_formname"><?php
esc_html_e('Form Name', 'gravityforms');
?>
: <?php
echo $form['title'];
?>
</span></span>
</h2>
<?php
RGForms::top_toolbar();
?>
<?php
if (false === empty($all_fields)) {
?>
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="side-info-column" class="inner-sidebar">
<div id="gresults-results-filter" class="postbox">
<h3 style="cursor: default;"><?php
echo $this->_search_title;
?>
//.........这里部分代码省略.........
示例2: get_form_init_scripts
public static function get_form_init_scripts($form)
{
$script_string = '';
// temporary solution for output gf_global obj until wp min version raised to 3.3
if (wp_script_is('gform_gravityforms')) {
$gf_global_script = "if(typeof gf_global == 'undefined') " . GFCommon::gf_global(false);
}
/* rendering initialization scripts */
$init_scripts = rgar(self::$init_scripts, $form['id']);
if (!empty($init_scripts)) {
$script_string = "<script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . ' ';
$script_string .= isset($gf_global_script) ? $gf_global_script : '';
$script_string .= "jQuery(document).bind('gform_post_render', function(event, formId, currentPage){" . "if(formId == {$form['id']}) {";
foreach ($init_scripts as $init_script) {
if ($init_script['location'] == self::ON_PAGE_RENDER) {
$script_string .= $init_script['script'];
}
}
$script_string .= "} " . "} );" . "jQuery(document).bind('gform_post_conditional_logic', function(event, formId, fields, isInit){";
foreach ($init_scripts as $init_script) {
if ($init_script['location'] == self::ON_CONDITIONAL_LOGIC) {
$script_string .= $init_script['script'];
}
}
$script_string .= "} );" . apply_filters('gform_cdata_close', '') . '</script>';
}
return $script_string;
}
示例3: forms_page
public static function forms_page($form_id)
{
global $wpdb;
if (!GFCommon::ensure_wp_version()) {
return;
}
$update_result = '';
if (rgpost('operation') == 'trash') {
check_admin_referer('gforms_trash_form', 'gforms_trash_form');
GFFormsModel::trash_form($form_id);
?>
<script type="text/javascript">
jQuery(document).ready(
function () {
document.location.href = '?page=gf_edit_forms';
}
);
</script>
<?php
exit;
} else {
if (!rgempty('gform_meta')) {
check_admin_referer("gforms_update_form_{$form_id}", 'gforms_update_form');
$update_result = self::save_form_info($form_id, rgpost('gform_meta', false));
}
}
require_once GFCommon::get_base_path() . '/currency.php';
wp_print_styles(array('thickbox'));
/* @var GF_Field_Address $gf_address_field */
$gf_address_field = GF_Fields::get('address');
?>
<link rel="stylesheet" href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css?ver=<?php
echo GFCommon::$version;
?>
" type="text/css" />
<script type="text/javascript">
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
</script>
<script type="text/javascript">
function has_entry(fieldNumber) {
var submitted_fields = [<?php
echo RGFormsModel::get_submitted_fields($form_id);
?>
];
for (var i = 0; i < submitted_fields.length; i++) {
if (submitted_fields[i] == fieldNumber)
return true;
}
return false;
}
function InsertPostImageVariable(element_id, callback) {
var variable = jQuery('#' + element_id + '_image_size_select').attr("variable");
var size = jQuery('#' + element_id + '_image_size_select').val();
if (size) {
variable = "{" + variable + ":" + size + "}";
InsertVariable(element_id, callback, variable);
jQuery('#' + element_id + '_image_size_select').hide();
jQuery('#' + element_id + '_image_size_select')[0].selectedIndex = 0;
}
}
function InsertPostContentVariable(element_id, callback) {
var variable = jQuery('#' + element_id + '_variable_select').val();
var regex = /{([^{]*?: *(\d+\.?\d*).*?)}/;
matches = regex.exec(variable);
if (!matches) {
InsertVariable(element_id, callback);
return;
}
variable = matches[1];
field_id = matches[2];
for (var i = 0; i < form["fields"].length; i++) {
if (form["fields"][i]["id"] == field_id) {
if (form["fields"][i]["type"] == "post_image") {
jQuery('#' + element_id + '_image_size_select').attr("variable", variable);
jQuery('#' + element_id + '_image_size_select').show();
return;
}
}
}
InsertVariable(element_id, callback);
}
//.........这里部分代码省略.........
示例4: export_lead_page
public static function export_lead_page()
{
if (!GFCommon::current_user_can_any('gravityforms_export_entries')) {
wp_die('You do not have permission to access this page');
}
self::page_header(__('Export Entries', 'gravityforms'));
?>
<script type="text/javascript">
var gfSpinner;
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
function SelectExportForm(formId) {
if (!formId)
return;
gfSpinner = new gfAjaxSpinner(jQuery('select#export_form'), gf_vars.baseUrl + '/images/spinner.gif', 'position: relative; top: 2px; left: 5px;');
var mysack = new sack("<?php
echo admin_url('admin-ajax.php');
?>
");
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar("action", "rg_select_export_form");
mysack.setVar("rg_select_export_form", "<?php
echo wp_create_nonce('rg_select_export_form');
?>
");
mysack.setVar("form_id", formId);
mysack.onError = function () {
alert(<?php
echo json_encode(__('Ajax error while selecting a form', 'gravityforms'));
?>
)
};
mysack.runAJAX();
return true;
}
function EndSelectExportForm(aryFields, filterSettings) {
gfSpinner.destroy();
if (aryFields.length == 0) {
jQuery("#export_field_container, #export_date_container, #export_submit_container").hide()
return;
}
var fieldList = "<li><input id='select_all' type='checkbox' onclick=\"jQuery('.gform_export_field').attr('checked', this.checked); jQuery('#gform_export_check_all').html(this.checked ? '<strong><?php
echo esc_js(__('Deselect All', 'gravityforms'));
?>
</strong>' : '<strong><?php
echo esc_js(__('Select All', 'gravityforms'));
?>
</strong>'); \"> <label id='gform_export_check_all' for='select_all'><strong><?php
esc_html_e('Select All', 'gravityforms');
?>
</strong></label></li>";
for (var i = 0; i < aryFields.length; i++) {
fieldList += "<li><input type='checkbox' id='export_field_" + i + "' name='export_field[]' value='" + aryFields[i][0] + "' class='gform_export_field'> <label for='export_field_" + i + "'>" + aryFields[i][1] + "</label></li>";
}
jQuery("#export_field_list").html(fieldList);
jQuery("#export_date_start, #export_date_end").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true});
jQuery("#export_field_container, #export_filter_container, #export_date_container, #export_submit_container").hide().show();
gf_vars.filterAndAny = <?php
echo json_encode(esc_html__('Export entries if {0} of the following match:', 'gravityforms'));
?>
;
jQuery("#export_filters").gfFilterUI(filterSettings);
}
jQuery(document).ready(function () {
jQuery("#gform_export").submit(function () {
if (jQuery(".gform_export_field:checked").length == 0) {
alert(<?php
echo json_encode(__('Please select the fields to be exported', 'gravityforms'));
?>
);
return false;
}
});
});
</script>
<p class="textleft"><?php
esc_html_e('Select a form below to export entries. Once you have selected a form you may select the fields you would like to export and then define optional filters for field values and the date range. When you click the download button below, Gravity Forms will create a CSV file for you to save to your computer.', 'gravityforms');
?>
//.........这里部分代码省略.........
示例5: results_page
public function results_page($form_id, $page_title, $gf_page, $gf_view)
{
if (empty($form_id)) {
$forms = RGFormsModel::get_forms();
if (!empty($forms)) {
$form_id = $forms[0]->id;
}
}
$form = GFFormsModel::get_form_meta($form_id);
$form = apply_filters("gform_form_pre_results_{$form_id}", apply_filters("gform_form_pre_results", $form));
// set up filter vars
$start_date = rgget("start");
$end_date = rgget("end");
$all_fields = $form["fields"];
$filter_settings = GFCommon::get_field_filter_settings($form);
$filter_settings = apply_filters("gform_filters_pre_results", $filter_settings, $form);
$filter_settings = array_values($filter_settings);
// reset the numeric keys in case some filters have been unset
$filter_fields = rgget("f");
$filter_operators = rgget("o");
$filter_values = rgget("v");
$filters = array();
$init_vars = array();
if (!empty($filter_fields)) {
$init_vars["mode"] = rgget("mode");
foreach ($filter_fields as $i => $filter_field) {
$filters[$i]["field"] = $filter_field;
$filters[$i]["operator"] = $filter_operators[$i];
$filters[$i]["value"] = $filter_values[$i];
}
$init_vars["filters"] = $filters;
}
?>
<script type="text/javascript">
var gresultsFields = <?php
echo json_encode($all_fields);
?>
;
var gresultsFilterSettings = <?php
echo json_encode($filter_settings);
?>
;
var gresultsInitVars = <?php
echo json_encode($init_vars);
?>
;
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
</script>
<link rel="stylesheet"
href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css?ver=<?php
echo GFCommon::$version;
?>
"
type="text/css"/>
<div class="wrap gforms_edit_form <?php
echo GFCommon::get_browser_class();
?>
">
<div class="icon32" id="gravity-entry-icon"><br></div>
<h2><?php
echo empty($form_id) ? $page_title : $page_title . " : " . esc_html($form["title"]);
?>
</h2>
<?php
RGForms::top_toolbar();
?>
<?php
if (false === empty($all_fields)) {
?>
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="side-info-column" class="inner-sidebar">
<div id="gresults-results-filter" class="postbox">
<h3 style="cursor: default;"><?php
echo $this->_search_title;
?>
</h3>
<div id="gresults-results-filter-content">
<form id="gresults-results-filter-form" action="" method="GET">
<input type="hidden" id="gresults-page-slug" name="page"
value="<?php
echo esc_attr($gf_page);
?>
">
<input type="hidden" id="gresults-view-slug" name="view"
value="<?php
//.........这里部分代码省略.........
示例6: form_settings_ui
public static function form_settings_ui()
{
require_once GFCommon::get_base_path() . '/form_detail.php';
require_once GFCommon::get_base_path() . '/currency.php';
$form_id = rgget('id');
$form = RGFormsModel::get_form_meta($form_id);
$update_result = array();
if (rgpost('gform_meta')) {
// die if not posted from correct page
check_admin_referer("gform_save_form_settings_{$form_id}", 'gform_save_form_settings');
$updated_form = json_decode(rgpost('gform_meta'), true);
$updated_form['fields'] = $form['fields'];
// -- standard form settings --
$updated_form['title'] = rgpost('form_title_input');
$updated_form['description'] = rgpost('form_description_input');
$updated_form['labelPlacement'] = rgpost('form_label_placement');
$updated_form['descriptionPlacement'] = rgpost('form_description_placement');
$updated_form['subLabelPlacement'] = rgpost('form_sub_label_placement');
// -- advanced form settings --
$updated_form['cssClass'] = rgpost('form_css_class');
$updated_form['enableHoneypot'] = rgpost('form_enable_honeypot');
$updated_form['enableAnimation'] = rgpost('form_enable_animation');
// form button settings
$updated_form['button']['type'] = rgpost('form_button');
$updated_form['button']['text'] = rgpost('form_button') == 'text' ? rgpost('form_button_text_input') : '';
$updated_form['button']['imageUrl'] = rgpost('form_button') == 'image' ? rgpost('form_button_image_url') : '';
// Save and Continue settings
$updated_form['save']['enabled'] = rgpost('form_save_enabled');
$updated_form['save']['button']['type'] = 'link';
$updated_form['save']['button']['text'] = rgpost('form_save_button_text');
// limit entries settings
$updated_form['limitEntries'] = rgpost('form_limit_entries');
$updated_form['limitEntriesCount'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_count') : '';
$updated_form['limitEntriesPeriod'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_period') : '';
$updated_form['limitEntriesMessage'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_message') : '';
// form scheduling settings
$updated_form['scheduleForm'] = rgpost('form_schedule_form');
$updated_form['scheduleStart'] = $updated_form['scheduleForm'] ? rgpost('gform_schedule_start') : '';
$updated_form['scheduleStartHour'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_hour') : '';
$updated_form['scheduleStartMinute'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_minute') : '';
$updated_form['scheduleStartAmpm'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_ampm') : '';
$updated_form['scheduleEnd'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end') : '';
$updated_form['scheduleEndHour'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_hour') : '';
$updated_form['scheduleEndMinute'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_minute') : '';
$updated_form['scheduleEndAmpm'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_ampm') : '';
$updated_form['schedulePendingMessage'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_pending_message') : '';
$updated_form['scheduleMessage'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_message') : '';
// require login settings
$updated_form['requireLogin'] = rgpost('form_require_login');
$updated_form['requireLoginMessage'] = $updated_form['requireLogin'] ? rgpost('form_require_login_message') : '';
$updated_form = GFFormsModel::maybe_sanitize_form_settings($updated_form);
if ($updated_form['save']['enabled']) {
$updated_form = self::activate_save($updated_form);
} else {
$updated_form = self::deactivate_save($updated_form);
}
$updated_form = apply_filters('gform_pre_form_settings_save', $updated_form);
$update_result = GFFormDetail::save_form_info($form_id, addslashes(json_encode($updated_form)));
// update working form object with updated form object
$form = $updated_form;
}
$form = gf_apply_filters('gform_admin_pre_render', $form_id, $form);
self::page_header(__('Form Settings', 'gravityforms'));
?>
<script type="text/javascript">
<?php
GFCommon::gf_global();
?>
var form = <?php
echo json_encode($form);
?>
;
var fieldSettings = [];
jQuery(document).ready(function ($) {
HandleUnsavedChanges('#gform_form_settings');
jQuery('.datepicker').datepicker({showOn: 'both', changeMonth: true, changeYear: true, buttonImage: "<?php
echo GFCommon::get_base_url();
?>
/images/calendar.png", buttonImageOnly: true});
ToggleConditionalLogic(true, 'form_button');
jQuery('tr:hidden .gf_animate_sub_settings').hide();
jQuery(document).trigger('gform_load_form_settings', [form]);
});
/**
* New Form Settings Functions
*/
function SaveFormSettings() {
//.........这里部分代码省略.........
示例7: export_lead_page
public static function export_lead_page()
{
self::page_header(__('Export Entries'));
?>
<script type="text/javascript">
var gfSpinner;
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
function SelectExportForm(formId){
if(!formId)
return;
gfSpinner = new gfAjaxSpinner(jQuery('select#export_form'), gf_vars.baseUrl + '/images/spinner.gif', 'position: relative; top: 2px; left: 5px;');
var mysack = new sack("<?php
echo admin_url("admin-ajax.php");
?>
" );
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar( "action", "rg_select_export_form" );
mysack.setVar( "rg_select_export_form", "<?php
echo wp_create_nonce("rg_select_export_form");
?>
" );
mysack.setVar( "form_id", formId);
mysack.onError = function() { alert('<?php
echo esc_js(__("Ajax error while selecting a form", "gravityforms"));
?>
' )};
mysack.runAJAX();
return true;
}
function EndSelectExportForm(aryFields){
gfSpinner.destroy();
if(aryFields.length == 0)
{
jQuery("#export_field_container, #export_date_container, #export_submit_container").hide()
return;
}
var fieldList = "<li><input id='select_all' type='checkbox' onclick=\"jQuery('.gform_export_field').attr('checked', this.checked); jQuery('#gform_export_check_all').html(this.checked ? '<strong><?php
_e("Deselect All", "gravityforms");
?>
</strong>' : '<strong><?php
_e("Select All", "gravityforms");
?>
</strong>'); \"> <label id='gform_export_check_all' for='select_all'><strong><?php
_e("Select All", "gravityforms");
?>
</strong></label></li>";
for(var i=0; i<aryFields.length; i++){
fieldList += "<li><input type='checkbox' id='export_field_" + i + "' name='export_field[]' value='" + aryFields[i][0] + "' class='gform_export_field'> <label for='export_field_" + i + "'>" + aryFields[i][1] + "</label></li>";
}
jQuery("#export_field_list").html(fieldList);
jQuery("#export_date_start, #export_date_end").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true});
jQuery("#export_field_container, #export_date_container, #export_submit_container").hide().show();
}
</script>
<p class="textleft"><?php
_e("Select a form below to export entries. Once you have selected a form you may select the fields you would like to export and an optional date range. When you click the download button below, Gravity Forms will create a CSV file for you to save to your computer.", "gravityforms");
?>
</p>
<div class="hr-divider"></div>
<form method="post" style="margin-top:10px;">
<?php
echo wp_nonce_field("rg_start_export", "rg_start_export_nonce");
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="export_form"><?php
_e("Select A Form", "gravityforms");
?>
</label> <?php
gform_tooltip("export_select_form");
?>
</th>
<td>
<select id="export_form" name="export_form" onchange="SelectExportForm(jQuery(this).val());">
<option value=""><?php
_e("Select a form", "gravityforms");
?>
</option>
//.........这里部分代码省略.........
示例8: leads_page
//.........这里部分代码省略.........
<script type="text/javascript">
var get_params = function(search_string) {
var parse = function(params, pairs) {
var pair = pairs[0];
var parts = pair.split('=');
var key = decodeURIComponent(parts[0]);
var value = decodeURIComponent(parts.slice(1).join('='));
//is key an array?
if(key.indexOf('[') > -1){
//yes, remove the [x] part
var newparts = key.split('[');
key = decodeURIComponent(newparts[0]);
}
// Handle multiple parameters of the same name
if (typeof params[key] === "undefined") {
params[key] = value;
} else {
params[key] = [].concat(params[key], value);
}
return pairs.length == 1 ? params : parse(params, pairs.slice(1))
}
// Get rid of leading ?
return search_string.length == 0 ? {} : parse({}, search_string.substr(1).split('&'));
}
var params = get_params(location.search);
<?php
GFCommon::gf_global();
?>
<?php
GFCommon::gf_vars();
?>
var messageTimeout = false,
gformFieldFilters = <?php
echo json_encode($field_filters);
?>
,
gformInitFilter = <?php
echo json_encode($init_filter_vars);
?>
function ChangeColumns(columns) {
jQuery("#action").val("change_columns");
jQuery("#grid_columns").val(jQuery.toJSON(columns));
tb_remove();
jQuery("#lead_form")[0].submit();
}
function Search(sort_field_id, sort_direction, form_id, search, star, read, filter, field_id, operator) {
var faire = "&faire="+jQuery('#faire').val();
var star_qs = star == "" ? "" : "&star=" + star;
var read_qs = read == "" ? "" : "&read=" + read;
var filter_qs = filter == "" ? "" : "&filter=" + filter;
//add to filter array
var filterField="";
//first, check if there are other filters set in the url
// if there are, be sure to include them
if(params['filterField'] != undefined){
if(jQuery.isArray(params['filterField'])){