function yandex_metrics_main_settings in Yandex.Metrics 7.3
Same name and namespace in other branches
- 6.2 yandex_metrics.module \yandex_metrics_main_settings()
- 6 yandex_metrics.module \yandex_metrics_main_settings()
- 7 yandex_metrics.module \yandex_metrics_main_settings()
- 7.2 yandex_metrics.module \yandex_metrics_main_settings()
The main module settings form.
1 string reference to 'yandex_metrics_main_settings'
- yandex_metrics_menu in ./
yandex_metrics.module - Implements hook_menu().
File
- ./
yandex_metrics.module, line 55 - The main code of Yandex.Metrics Counter module.
Code
function yandex_metrics_main_settings($form, $form_state) {
// Build multidomain form with Variable API.
if (module_exists('domain_variable')) {
return variable_module_form($form, $form_state, 'yandex_metrics');
}
$form['yandex_metrics_counter_code'] = array(
'#default_value' => variable_get('yandex_metrics_counter_code', ''),
'#title' => t('Counter Code'),
'#type' => 'textarea',
'#rows' => 10,
'#description' => t('Paste Yandex.Metrica counter code for your site here.'),
);
$form['visibility'] = array(
'#type' => 'fieldset',
'#title' => t('Page specific tracking settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$visibility = variable_get('yandex_metrics_visibility', 0);
$options = array(
t('Add to every page except the listed pages.'),
t('Add to the listed pages only.'),
);
$form['visibility']['yandex_metrics_visibility'] = array(
'#type' => 'radios',
'#title' => t('Add code to specific pages'),
'#options' => $options,
'#default_value' => $visibility,
);
$pages = variable_get('yandex_metrics_pages', YANDEX_METRICS_PAGES);
$description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
$form['visibility']['yandex_metrics_pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => $pages,
'#description' => $description,
'#wysiwyg' => FALSE,
'#rows' => 10,
);
// Render the role overview.
$form['role_visibility'] = array(
'#type' => 'fieldset',
'#title' => t('Role specific tracking settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['role_visibility']['yandex_metrics_visibility_roles'] = array(
'#type' => 'radios',
'#title' => t('Add tracking for specific roles'),
'#options' => array(
t('Add to the selected roles only'),
t('Add to every role except the selected ones'),
),
'#default_value' => variable_get('yandex_metrics_visibility_roles', 0),
);
$roles = user_roles();
$role_options = array();
foreach ($roles as $rid => $name) {
$role_options[$rid] = $name;
}
$form['role_visibility']['yandex_metrics_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#default_value' => variable_get('yandex_metrics_roles', array()),
'#options' => $role_options,
'#description' => t('If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked (or excluded, depending on the setting above).'),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}