You are here

cookie_content_blocker_media.variable.inc in Cookie Content Blocker 7

Contains the variables used by Cookie content blocker - Media.

This file is used by the Variable module, but also read in as fallback when this module is not available.

File

modules/cookie_content_blocker_media/cookie_content_blocker_media.variable.inc
View source
<?php

/**
 * @file
 * Contains the variables used by Cookie content blocker - Media.
 *
 * This file is used by the Variable module, but also read in as fallback when
 * this module is not available.
 */

/**
 * Implements hook_variable_info().
 */
function cookie_content_blocker_media_variable_info($options) {
  $variables = array();
  $providers = media_internet_get_providers();
  foreach ($providers as $provider) {
    $variable_blocked_name = _cookie_content_blocker_media_provider_variable_name($provider, 'blocked');
    $variables[$variable_blocked_name] = array(
      'type' => 'boolean',
      'title' => t('Block %provider media', array(
        '%provider' => $provider['title'],
      ), $options),
      'description' => t('Enable blocking of all %provider media until consent is given.', array(
        '%provider' => $provider['title'],
      ), $options),
      'default' => FALSE,
      'group' => 'cookie_content_blocker',
      'element' => array(
        '#media_provider' => $provider['title'],
      ),
    );
    $variable_show_preview_name = _cookie_content_blocker_media_provider_variable_name($provider, 'show_preview');
    $variables[$variable_show_preview_name] = array(
      'type' => 'boolean',
      'title' => t('Show a preview for blocked content', $options),
      'default' => FALSE,
      'group' => 'cookie_content_blocker',
      'element' => array(
        '#media_provider' => $provider['title'],
        '#states' => array(
          'visible' => array(
            ':input[name="' . $variable_blocked_name . '"]' => array(
              'checked' => TRUE,
            ),
          ),
        ),
      ),
    );
    $variable_preview_style_name = _cookie_content_blocker_media_provider_variable_name($provider, 'preview_style');
    $variables[$variable_preview_style_name] = array(
      'type' => 'select',
      'title' => t('Choose an image style to use for the preview.', $options),
      'options' => image_style_options(FALSE),
      'default' => 'blocked_media_teaser',
      'group' => 'cookie_content_blocker',
      'element' => array(
        '#media_provider' => $provider['title'],
        '#states' => array(
          'visible' => array(
            ':input[name="' . $variable_show_preview_name . '"]' => array(
              'checked' => TRUE,
            ),
          ),
        ),
      ),
    );
    $variable_blocked_message_name = _cookie_content_blocker_media_provider_variable_name($provider, 'blocked_message');
    $variables[$variable_blocked_message_name] = array(
      'type' => 'text',
      'title' => t('Message for blocked %provider media', array(
        '%provider' => $provider['title'],
      ), $options),
      'description' => t('When %provider media is blocked and a message is shown, this message will be shown.', array(
        '%provider' => $provider['title'],
      ), $options),
      'default' => t('You have not yet given permission to place the required cookies. Accept the required cookies to view this content.', array(), $options),
      'group' => 'cookie_content_blocker',
      'localize' => TRUE,
      'element' => array(
        '#media_provider' => $provider['title'],
        '#states' => array(
          'visible' => array(
            ':input[name="' . $variable_blocked_name . '"]' => array(
              'checked' => TRUE,
            ),
          ),
        ),
      ),
    );
  }
  return $variables;
}