You are here

public function BlazyLibrary::isActive in Blazy 7

Checks if Blazy is for the current URL, required by BlazyFilter at D7.

Return value

bool TRUE if Blazy is active for the current page.

1 call to BlazyLibrary::isActive()
BlazyLibrary::pageBuild in src/BlazyLibrary.php
Implements hook_page_build().

File

src/BlazyLibrary.php, line 195

Class

BlazyLibrary
Provides Blazy library definitions.

Namespace

Drupal\blazy

Code

public function isActive() {
  if (!isset($this->isActive)) {
    $this->isActive = FALSE;

    // Make it possible deactivate Blazy with
    // parameter ?blazy=no in the url.
    if (isset($_GET['blazy']) && $_GET['blazy'] == 'no') {
      return $this->isActive;
    }

    // Code from the block_list function in block.module.
    $path = drupal_get_path_alias($_GET['q']);
    $pages = $this->manager
      ->config('pages', BlazyDefault::PAGES, 'blazy.settings');

    // Compare with the internal and path alias (if any).
    $page_match = drupal_match_path($path, $pages);
    if ($path != $_GET['q']) {
      $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
    }
    $page_match = $this->manager
      ->config('visibility', 0, 'blazy.settings') == 0 ? !$page_match : $page_match;

    // Allow other modules to change the state of blazy for the current URL.
    drupal_alter('blazy_active', $page_match);
    $this->isActive = $page_match;
  }
  return $this->isActive;
}