You are here

context_omega.module in Context omega 7

Main module file for the Omega context integration module.

File

context_omega.module
View source
<?php

/**
 * @file
 * Main module file for the Omega context integration module.
 */

/**
 * Implements hook_context_plugins().
 */
function context_omega_context_plugins() {
  $plugins['context_omega_reaction_omega_layout'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'context_omega') . '/plugins',
      'file' => 'context_omega_reaction_omega_layout.inc',
      'class' => 'context_omega_reaction_omega_layout',
      'parent' => 'context_reaction_block',
    ),
  );
  return $plugins;
}

/**
 * Implements hook_context_registry_alter().
 */
function context_omega_context_registry_alter(&$registry) {
  if (isset($registry['reactions']['block'])) {
    $registry['reactions']['block']['title'] = t('Blocks and Omega');
    $registry['reactions']['block']['plugin'] = 'context_omega_reaction_omega_layout';
  }
}

/**
 * Implements hook_omega_layout_alter().
 */
function context_omega_omega_layout_alter(&$layout) {
  if ($plugin = context_get_plugin('reaction', 'block')) {
    $reaction_layout = $plugin
      ->get_active_layout();
    if (!empty($reaction_layout) && array_key_exists($reaction_layout, context_omega_get_layouts())) {

      // Override the active Omega layout with the one specified by one of the
      // active contexts. If none of the active contexts specified a layout the
      // active Omega layout stays unaffected.
      $layout = $reaction_layout;
    }
  }
}

/**
 * Get all the layouts from the theme.
 */
function context_omega_get_layouts() {

  // Check if the function exists.
  if (function_exists('omega_layouts_info')) {
    return omega_layouts_info();
  }

  // If not try loading the omega include file.
  $file = drupal_get_path('theme', 'omega') . '/includes/omega.inc';
  if (is_file($file)) {
    require_once $file;
    return omega_layouts_info();
  }
  return array();
}

/**
 * Implements hook_init().
 */
function context_omega_init() {
  if ($plugin = context_get_plugin('condition', 'sitewide')) {
    $plugin
      ->execute(TRUE);
  }
}

Functions

Namesort descending Description
context_omega_context_plugins Implements hook_context_plugins().
context_omega_context_registry_alter Implements hook_context_registry_alter().
context_omega_get_layouts Get all the layouts from the theme.
context_omega_init Implements hook_init().
context_omega_omega_layout_alter Implements hook_omega_layout_alter().