function ga_stats_admin_settings in Google Analytics Statistics 7.x
Same name and namespace in other branches
- 7.2 ga_stats.admin.inc \ga_stats_admin_settings()
- 7 ga_stats.admin.inc \ga_stats_admin_settings()
1 string reference to 'ga_stats_admin_settings'
File
- ./
ga_stats.module, line 125
Code
function ga_stats_admin_settings() {
$form = array();
$form['ga_stats_login'] = array(
'#type' => 'fieldset',
'#title' => t('Google Analytics Login Information'),
'#collapsible' => TRUE,
);
$form['ga_stats_login']['ga_stats_email'] = array(
'#type' => 'textfield',
'#title' => t('Account Email'),
'#description' => t('The email account you use to log in to Google Analytics'),
'#default_value' => variable_get('ga_stats_email', ''),
);
$form['ga_stats_login']['ga_stats_password'] = array(
'#type' => 'password',
'#title' => t('Account Password'),
'#description' => t('The password you use to log in to Google Analytics'),
'#default_value' => variable_get('ga_stats_password', ''),
);
$form['ga_stats_accounts'] = array(
'#type' => 'fieldset',
'#title' => t('Google Analytics Tracking Accounts'),
'#collapsible' => TRUE,
);
if (variable_get('ga_stats_email', false) && variable_get('ga_stats_password', false)) {
$account = ga_stats_ga_get_accounts();
}
else {
$account = false;
}
$options = array();
if (is_array($account)) {
foreach ($account as $id => $value) {
$acc = $value
->getProperties();
$options[$acc['profileId']] = $acc['title'];
}
}
if ($options) {
$form['ga_stats_accounts']['ga_stats_profile'] = array(
'#type' => 'select',
'#title' => t('Google Analytics Profile to Use'),
'#description' => t('The Google Analytics profile from which to retrieve statistics'),
'#options' => $options,
'#default_value' => variable_get('ga_stats_profile', ''),
);
}
else {
$form['ga_stats_accounts']['ga_stats_profile'] = array(
'#type' => 'markup',
'#markup' => '<div class="messages warning">' . t('Email and Pasword not set or invalid. Please set the login information and save this form. You will then be able to view and configure account information.') . '</div>',
);
}
$form['enabled_stats'] = array(
'#type' => 'fieldset',
'#title' => t('Enabled Statistics'),
'#description' => t('Make sure to clear the Drupal cache after changing this setting in order to inform Views of the new settings. <br/><em><b>WARNING:</b> Do not disable a setting which is currently in use in Views.</em>'),
);
$form['enabled_stats']['ga_stats_enabled_metrics'] = array(
'#type' => 'checkboxes',
'#default_value' => variable_get('ga_stats_enabled_metrics', array(
'pageviews',
)),
'#options' => ga_stats_ga_metrics(true),
'#title' => t('Metrics'),
'#description' => t('The metrics that will be available from Google Analytics in Views.'),
);
$form['enabled_stats']['ga_stats_enabled_timeframes'] = array(
'#type' => 'checkboxes',
'#default_value' => variable_get('ga_stats_enabled_timeframes', array(
'today',
'month',
)),
'#options' => ga_stats_ga_timeframes(true, true),
'#title' => t('Time Frames'),
'#description' => t('The timeframes that will be available from Google Analytics in Views.'),
);
$form['ga_stats_max_results'] = array(
'#type' => 'textfield',
'#title' => t('Max Results per Metric/Timeframe'),
'#description' => t('The max results that a call (a metric/timeframe combination) can return. MUST be a number.'),
'#default_value' => variable_get('ga_stats_max_results', '100'),
);
if (variable_get('ga_stats_profile', false)) {
$form['actions']['ga_stats_update'] = array(
'#type' => 'button',
'#value' => t('Update Counts'),
'#weight' => 20,
'#executes_submit_callback' => TRUE,
'#submit' => array(
'ga_stats_update_counts',
),
);
}
return system_settings_form($form);
}