You are here

function mappy_page_build in Mappy 7

Same name and namespace in other branches
  1. 8 mappy.module \mappy_page_build()

Implements hook_page_build().

File

./mappy.module, line 28
Module file for mappy.

Code

function mappy_page_build(&$page) {

  // Patterns for matching.
  $pages = drupal_strtolower(variable_get('mappy_load_pages_path'));

  // Convert path alias to lowercase.
  $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

  // Compare pages to aliased path.
  $page_match = drupal_match_path($path, $pages);

  // Compare for original paths.
  if ($path != $_GET['q']) {
    $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
  }

  // Type of the matching path.
  // 0 - All pages except those listed.
  // 1 - Only the listed pages.
  $match_type = variable_get('mappy_load_pages_match', 0);

  // First comparsion for 'All pages except those listed'.
  // Second for 'Only the listed pages'.
  if ($match_type == "0" && !$page_match || $match_type && $page_match) {

    // Add settings to js file.
    drupal_add_js(array(
      'mappy_location' => drupal_get_path('module', 'mappy'),
      'mappy_google_width' => variable_get('mappy_google_width', 640),
      'mappy_google_height' => variable_get('mappy_google_height', 480),
      'mappy_yandex_width' => variable_get('mappy_yandex_width', 640),
      'mappy_yandex_height' => variable_get('mappy_yandex_height', 480),
      'mappy_yandex_version' => variable_get('mappy_yandex_version', 2),
    ), 'setting');
    drupal_add_js(drupal_get_path('module', 'mappy') . '/js/mappy.js');
  }
}