You are here

function copyprevention_page_build in Copy Prevention 7

Implements hook_page_build().

File

./copyprevention.module, line 60
Main file for Copy Prevention module.

Code

function copyprevention_page_build(&$page) {
  $children = element_children($page);
  $region = array_shift($children);
  $copyprevention_images_search = array_filter(variable_get('copyprevention_images_search', array()));
  if (array_key_exists('httpheader', $copyprevention_images_search)) {
    $page[$region]['#attached']['drupal_add_http_header'][] = array(
      'X-Robots-Tag',
      'noimageindex',
      TRUE,
    );
  }
  if (array_key_exists('pagehead', $copyprevention_images_search)) {
    $data = array(
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => 'robots',
        'content' => 'noimageindex',
      ),
    );
    $page[$region]['#attached']['drupal_add_html_head'][] = array(
      $data,
      'copyprevention_images_search',
    );
  }
  if (user_access('bypass copy prevention')) {
    return;
  }
  $path = drupal_get_path('module', 'copyprevention');
  $page[$region]['#attached']['js'][] = array(
    'data' => array(
      'copyprevention' => array(
        'body' => array_filter(variable_get('copyprevention_body', array())),
        'images' => array_filter(variable_get('copyprevention_images', array())),
        'images_min_dimension' => variable_get('copyprevention_images_min_dimension', 150),
        'transparentgif' => file_create_url($path . '/transparent.gif'),
      ),
    ),
    'type' => 'setting',
  );
  $page[$region]['#attached']['js'][$path . '/copyprevention.js'] = array(
    'scope' => 'footer',
  );
}