You are here

context_error.module in Context error 6

Same filename and directory in other branches
  1. 7 context_error.module

Implement triggers for 404 and 403 pages.

File

context_error.module
View source
<?php

/**
 * @file
 * Implement triggers for 404 and 403 pages.
 */

/**
 * Implements hook_context_plugins().
 */
function context_error_context_plugins() {
  $plugins = array();
  $plugins['context_error_context_condition_error'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'context_error') . '/plugins',
      'file' => 'context_error_context_conditions.inc',
      'class' => 'context_error_context_condition_error',
      'parent' => 'context_condition',
    ),
  );
  return $plugins;
}

/**
 * Implements hook_context_registry().
 */
function context_error_context_registry() {
  return array(
    'conditions' => array(
      'error' => array(
        'title' => t('404/403 error page'),
        'plugin' => 'context_error_context_condition_error',
      ),
    ),
  );
}

/**
 * Implements of hook_context_page_condition().
 */
function context_error_context_page_condition() {
  if ($plugin = context_get_plugin('condition', 'error')) {
    $plugin
      ->execute();
  }
}

/**
 * Parse the HTTP response from the headers currently set by Drupal.
 */
function context_error_get_response_from_headers() {
  $headers = drupal_get_headers();
  $response = 200;
  if (FALSE !== ($status_pos = strpos($headers, ':status:'))) {
    $response = substr($headers, $status_pos + 9, 3);
  }
  return $response;
}

Functions

Namesort descending Description
context_error_context_page_condition Implements of hook_context_page_condition().
context_error_context_plugins Implements hook_context_plugins().
context_error_context_registry Implements hook_context_registry().
context_error_get_response_from_headers Parse the HTTP response from the headers currently set by Drupal.