piwik.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 piwik_variable_info($options) {
  10. $variables['piwik_site_id'] = array(
  11. 'type' => 'string',
  12. 'title' => t('Piwik 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 Piwik account, then the <strong>Websites</strong> tab and enter the appropriate site <strong>ID</strong> into this field.'),
  15. 'required' => TRUE,
  16. 'group' => 'piwik',
  17. 'localize' => TRUE,
  18. 'multidomain' => TRUE,
  19. 'validate callback' => 'piwik_validate_piwik_site_id',
  20. );
  21. return $variables;
  22. }
  23. /**
  24. * Implements hook_variable_group_info().
  25. */
  26. function piwik_variable_group_info() {
  27. $groups['piwik'] = array(
  28. 'title' => t('Piwik'),
  29. 'description' => t('Configure tracking behavior to get insights into your website traffic and marketing effectiveness.'),
  30. 'access' => 'administer piwik',
  31. 'path' => array('admin/config/system/piwik'),
  32. );
  33. return $groups;
  34. }
  35. /**
  36. * Validate Piwik site ID variable.
  37. *
  38. * @param array $variable
  39. *
  40. * @return string
  41. */
  42. function piwik_validate_piwik_site_id($variable) {
  43. if (!preg_match('/^\d{1,}$/', $variable['value'])) {
  44. return t('A valid Piwik site ID is an integer only.');
  45. }
  46. }