You are here

function advagg_mod_match_path in Advanced CSS/JS Aggregation 7.2

Transforms all CSS files into inline CSS.

Parameters

string $pages: String from the advagg_mod_inline_pages variable.

int $visibility: Visibility setting from the advagg_mod_inline_visibility variable.

Return value

bool TRUE if the current path matches the given pages.

See also

block_block_list_alter()

4 calls to advagg_mod_match_path()
advagg_mod_css_defer_page in advagg_mod/advagg_mod.module
Returns TRUE if this page should have critical CSS inlined.
advagg_mod_inline_page in advagg_mod/advagg_mod.module
Returns TRUE if this page should have inline CSS and JS.
advagg_mod_inline_page_css in advagg_mod/advagg_mod.module
Returns TRUE if this page should have inline CSS.
advagg_mod_inline_page_js in advagg_mod/advagg_mod.module
Returns TRUE if this page should have inline JS.

File

advagg_mod/advagg_mod.module, line 3366
Advanced aggregation modifier module.

Code

function advagg_mod_match_path($pages, $visibility) {

  // Default to not matching.
  $page_match = FALSE;

  // Limited visibility blocks must list at least one page.
  if (empty($pages) && $visibility <= ADVAGG_MOD_VISIBILITY_PHP) {
    if ($visibility == ADVAGG_MOD_VISIBILITY_NOTLISTED) {
      $page_match = TRUE;
    }
  }
  else {

    // Match on php.
    if ($visibility == ADVAGG_MOD_VISIBILITY_PHP) {
      if (module_exists('php')) {
        $page_match = php_eval($pages);
      }
    }
    elseif ($visibility < ADVAGG_MOD_VISIBILITY_PHP) {
      $current_path = current_path();

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

      // Convert the Drupal path to lowercase.
      $path = drupal_strtolower(drupal_get_path_alias($current_path));

      // Compare the lowercase internal and lowercase path alias (if any).
      $page_match = drupal_match_path($path, $pages);
      if ($path != $current_path) {
        $page_match = $page_match || drupal_match_path($current_path, $pages);
      }

      // When $visibility has a value of 0 (ADVAGG_MOD_VISIBILITY_NOTLISTED),
      // the block is displayed on all pages except those listed in $pages.
      // When set to 1 (ADVAGG_MOD_VISIBILITY_LISTED), it is displayed only on
      // those pages listed in $block->pages.
      $page_match = !($visibility xor $page_match);
    }
  }
  return $page_match;
}