Projet

Général

Profil

Paste
Télécharger (1,38 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / matomo / matomo.variable.inc @ 60283730

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of variables for Variable API module.
6
 */
7

    
8
/**
9
 * Implements hook_variable_info().
10
 */
11
function matomo_variable_info($options) {
12
  $variables['matomo_site_id'] = array(
13
    'type' => 'string',
14
    'title' => t('Matomo site ID', array(), $options),
15
    'default' => '',
16
    'description' => t('The user account number is unique to the websites domain. Click the <strong>Settings</strong> link in your Matomo account, then the <strong>Websites</strong> tab and enter the appropriate site <strong>ID</strong> into this field.'),
17
    'required' => TRUE,
18
    'group' => 'matomo',
19
    'localize' => TRUE,
20
    'multidomain' => TRUE,
21
    'validate callback' => 'matomo_validate_matomo_site_id',
22
  );
23

    
24
  return $variables;
25
}
26

    
27
/**
28
 * Implements hook_variable_group_info().
29
 */
30
function matomo_variable_group_info() {
31
  $groups['matomo'] = array(
32
    'title' => t('Matomo'),
33
    'description' => t('Configure tracking behavior to get insights into your website traffic and marketing effectiveness.'),
34
    'access' => 'administer matomo',
35
    'path' => array('admin/config/system/matomo'),
36
  );
37

    
38
  return $groups;
39
}
40

    
41
/**
42
 * Validate Matomo site ID variable.
43
 *
44
 * @param array $variable
45
 *
46
 * @return string
47
 */
48
function matomo_validate_matomo_site_id($variable) {
49
  if (!preg_match('/^\d{1,}$/', $variable['value'])) {
50
    return t('A valid Matomo site ID is an integer only.');
51
  }
52
}