You are here

function _shadowbox_activation in Shadowbox 7.4

Same name and namespace in other branches
  1. 8 shadowbox.module \_shadowbox_activation()
  2. 7.3 shadowbox.module \_shadowbox_activation()

Verify that Shadowbox should be activation for the current URL.

Return value

TRUE if Shadowbox should be activation for the current page.

3 calls to _shadowbox_activation()
file_shadowbox_field_formatter_view in file_shadowbox/file_shadowbox.module
Implements hook_field_formatter_view().
image_shadowbox_field_formatter_view in image_shadowbox/image_shadowbox.module
Implements hook_field_formatter_view().
_shadowbox_construct_header in ./shadowbox.module
Build the Shadowbox header by adding the necessary CSS and JS files.

File

./shadowbox.module, line 249
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function _shadowbox_activation() {
  $pages = variable_get('shadowbox_pages', "admin*\nimg_assist*\nnode/add/*\nnode/*/edit");
  $activation = variable_get('shadowbox_activation_type', SHADOWBOX_ACTIVATION_NOTLISTED);

  // Match path if necessary.
  if ($pages) {

    // Convert path to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $lowercase_pages = drupal_strtolower($pages);
    if ($activation < SHADOWBOX_ACTIVATION_PHP) {

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

      // Compare the lowercase internal and lowercase path alias (if any).
      $page_match = drupal_match_path($path, $lowercase_pages);
      if ($path != $_GET['q']) {
        $page_match = $page_match || drupal_match_path($_GET['q'], $lowercase_pages);
      }

      // When $ACTIVATION has a value of 0 (SHADOWBOX_ACTIVATION_NOTLISTED),
      // shadowbox is added on all pages except those listed in $pages.
      // When set to 1 (SHADOWBOX_ACTIVATION_LISTED),
      // it is added only on those pages listed in $pages.
      $page_match = !($activation xor $page_match);
    }
    elseif (module_exists('php')) {
      $page_match = php_eval($pages);
    }
    else {
      $page_match = FALSE;
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match;
}