matomo.variable.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Definition of variables for Variable API module.
  5. */
  6. /**
  7. * Implements hook_variable_info().
  8. */
  9. function matomo_variable_info($options) {
  10. $variables['matomo_site_id'] = array(
  11. 'type' => 'string',
  12. 'title' => t('Matomo site ID', array(), $options),
  13. 'default' => '',
  14. '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.'),
  15. 'required' => TRUE,
  16. 'group' => 'matomo',
  17. 'localize' => TRUE,
  18. 'multidomain' => TRUE,
  19. 'validate callback' => 'matomo_validate_matomo_site_id',
  20. );
  21. return $variables;
  22. }
  23. /**
  24. * Implements hook_variable_group_info().
  25. */
  26. function matomo_variable_group_info() {
  27. $groups['matomo'] = array(
  28. 'title' => t('Matomo'),
  29. 'description' => t('Configure tracking behavior to get insights into your website traffic and marketing effectiveness.'),
  30. 'access' => 'administer matomo',
  31. 'path' => array('admin/config/system/matomo'),
  32. );
  33. return $groups;
  34. }
  35. /**
  36. * Validate Matomo site ID variable.
  37. *
  38. * @param array $variable
  39. *
  40. * @return string
  41. */
  42. function matomo_validate_matomo_site_id($variable) {
  43. if (!preg_match('/^\d{1,}$/', $variable['value'])) {
  44. return t('A valid Matomo site ID is an integer only.');
  45. }
  46. }