analytics_amp.module in Analytics 7
File
analytics_amp/analytics_amp.module
View source
<?php
function analytics_amp_analytics_service_info() {
$info['amp-analytics'] = array(
'label' => t('AMP'),
'class' => 'AmpAnalyticsService',
'multiple' => TRUE,
);
$info['amp-pixel'] = array(
'label' => t('AMP Tracking Pixel'),
'class' => 'AmpTrackingPixelAnalyticsService',
'multiple' => TRUE,
);
return $info;
}
function analytics_amp_element_validate_config_url($element, &$form_state) {
$value = $element['#value'];
if ($value == '') {
return;
}
elseif (file_valid_uri($value)) {
return;
}
else {
elements_validate_url($element, $form_state);
}
}
function analytics_amp_element_validate_config_json($element, &$form_state) {
$value = $element['#value'];
if ($value == '') {
return;
}
elseif (is_string($value)) {
$data = json_decode($value, TRUE);
if (json_last_error()) {
form_error($element, t('%name is not valid JSON.', array(
'%name' => $element['#title'],
)));
}
elseif ($element['#required'] && empty($data)) {
form_error($element, t('%name is required.', array(
'%name' => $element['#title'],
)));
}
else {
form_set_value($element, $data, $form_state);
}
}
}