You are here

analytics_piwik.module in Analytics 7

File

analytics_piwik/analytics_piwik.module
View source
<?php

/**
 * Implememts hook_hook_info().
 */
function analytics_piwik_hook_info() {
  $info['analytics_piwik_universal_actions'] = array(
    'group' => 'analytics',
  );
  $info['analytics_piwik_universal_actions_alter'] = array(
    'group' => 'analytics',
  );
  return $info;
}

/**
 * Implements hook_theme().
 */
function analytics_piwik_theme() {
  $info['analytics_piwik_js'] = array(
    'variables' => array(
      'url' => NULL,
      'actions' => array(),
      'service' => NULL,
    ),
    'file' => 'analytics_piwik.theme.inc',
  );
  return $info;
}

/**
 * Implements hook_analytics_service_info().
 */
function analytics_piwik_analytics_service_info() {
  $info['piwik'] = array(
    'label' => t('Piwik'),
    'class' => 'PiwikAnalyticsService',
  );
  return $info;
}
function _analytics_piwik_validate_url($element, &$form_state) {
  $value = $element['#value'];
  if ($value != '') {

    // Make sure the URL is normalized.
    $value = rtrim($value, '/') . '/';
    form_set_value($element, $value, $form_state);
    if (!valid_url($value, TRUE)) {
      form_error($element, t('%name is not a valid URL.', array(
        '%name' => $element['#title'],
      )));
    }
    else {
      $request = drupal_http_request($value . '/piwik.js');
      if (!empty($request->error)) {

        //form_error($element, t('Error validating Piwki URL %url (@reason).', array('%url' => $value, '@reason' => $request->error)));
      }
    }
  }
}

Functions