You are here

class PiwikAnalyticsService in Analytics 7

Hierarchy

Expanded class hierarchy of PiwikAnalyticsService

1 string reference to 'PiwikAnalyticsService'
analytics_piwik_analytics_service_info in analytics_piwik/analytics_piwik.module
Implements hook_analytics_service_info().

File

analytics_piwik/src/PiwikAnalyticsService.php, line 3

View source
class PiwikAnalyticsService extends AnalyticsService {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return array(
      'url' => NULL,
      'id' => NULL,
    );
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm($form, &$form_state) {
    $options['url'] = array(
      '#type' => 'textfield',
      '#title' => t('URL'),
      '#description' => t('The URL to your Piwik base directory.'),
      '#default_value' => $this
        ->getConfiguration()['url'],
      '#element_validate' => array(
        '_analytics_piwik_validate_url',
      ),
      '#required' => TRUE,
    );
    $options['id'] = array(
      '#type' => 'textfield',
      '#title' => t('Site ID'),
      '#default_value' => $this
        ->getConfiguration()['id'],
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      '#required' => TRUE,
      '#size' => 10,
    );
    return $options;
  }
  public function getOutput(array $context) {
    $actions = array();
    $actions[] = array(
      'setSiteId',
      (int) $this
        ->getConfiguration()['id'],
    );
    $actions[] = "_paq.push(['setTrackerUrl', u+'piwik.php']);";
    $actions[] = array(
      'trackPageView',
    );
    $actions[] = array(
      'enableLinkTracking',
    );
    $actions = array_merge($actions, module_invoke_all('analytics_piwik_actions', $this, $context));
    drupal_alter('analytics_piwik_actions', $actions, $this, $context);
    $code = theme('analytics_piwik_js', array(
      'actions' => $actions,
      'service' => $this,
      'url' => $this->{$this}
        ->getConfiguration()['url'],
    ));
    $output = array();
    $output['#attached']['js'][] = array(
      'data' => $code,
      'type' => 'inline',
      //'weight' => 100000,
      'preprocess' => FALSE,
      'scope' => 'footer',
    );
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AnalyticsService::$description private property
AnalyticsService::$hasMultiple protected property
AnalyticsService::$label private property
AnalyticsService::$machine_name private property
AnalyticsService::$options private property
AnalyticsService::$service private property
AnalyticsService::canTrack public function Determines if the current service can track the current request. Overrides AnalyticsServiceInterface::canTrack
AnalyticsService::getAmpOutput public function Build an <amp-analytics> tag for output on an amp-enabled page request.
AnalyticsService::getCacheableUrls public function Overrides AnalyticsServiceInterface::getCacheableUrls 2
AnalyticsService::getConfiguration public function Overrides AnalyticsServiceInterface::getConfiguration
AnalyticsService::getDescription public function Returns the description of the plugin instance. Overrides AnalyticsServiceInterface::getDescription
AnalyticsService::getLabel public function Returns the label of the plugin instance. Overrides AnalyticsServiceInterface::getLabel
AnalyticsService::getMachineName public function Returns the machine name of the analytics plugin instance. Overrides AnalyticsServiceInterface::getMachineName
AnalyticsService::getService public function Returns the type of the plugin instance. Overrides AnalyticsServiceInterface::getService
AnalyticsService::hasMultipleInstances public function
AnalyticsService::__construct public function
PiwikAnalyticsService::buildConfigurationForm public function Form constructor. Overrides AnalyticsService::buildConfigurationForm
PiwikAnalyticsService::defaultConfiguration public function Overrides AnalyticsService::defaultConfiguration
PiwikAnalyticsService::getOutput public function Returns the output of the analytics service. Overrides AnalyticsServiceInterface::getOutput