You are here

class context_omega_reaction_omega_layout in Context omega 7

Hierarchy

Expanded class hierarchy of context_omega_reaction_omega_layout

2 string references to 'context_omega_reaction_omega_layout'
context_omega_context_plugins in ./context_omega.module
Implements hook_context_plugins().
context_omega_context_registry_alter in ./context_omega.module
Implements hook_context_registry_alter().

File

plugins/context_omega_reaction_omega_layout.inc, line 3

View source
class context_omega_reaction_omega_layout extends context_reaction_block {

  /**
   * Options form.
   */
  function options_form($context) {
    $form = parent::options_form($context);
    if ($layouts = context_omega_get_layouts()) {
      $options = $regions = array();
      foreach ($layouts as $key => $layout) {
        $regions[$key] = array_keys($layout['info']['regions']);
        $options[$key] = $layout['info']['name'];
      }
      asort($layouts);
      $values = $this
        ->fetch_from_context($context);
      $form['layout'] = array(
        '#title' => t('Choose an Omega layout'),
        '#description' => t('Choose the Omega layout to use.'),
        '#type' => 'select',
        '#options' => $options,
        '#default_value' => isset($values['layout']) ? $values['layout'] : NULL,
        '#weight' => -10,
        '#empty_value' => '_default',
        '#empty_option' => t('Default'),
        '#attributes' => array(
          'class' => array(
            'context-omega-layout-select',
          ),
        ),
      );
      drupal_add_js(drupal_get_path('module', 'context_omega') . '/plugins/context_omega_reaction_omega_layout.js');
      drupal_add_js(array(
        'contextOmega' => array(
          'regions' => $regions,
        ),
      ), 'setting');
    }
    return $form;
  }

  /**
   * Override of submit handler.
   */
  function options_form_submit($values) {
    $options = parent::options_form_submit($values);

    // Check whether a valid layout was selected.
    $layouts = context_omega_get_layouts();
    if (!empty($values['layout']) && isset($layouts[$values['layout']])) {
      $options['layout'] = $values['layout'];

      // Unset blocks attached to invalid regions.
      foreach ($options['blocks'] as $key => $block) {
        if (!isset($layouts[$options['layout']]['info']['regions'][$block['region']])) {
          unset($options['blocks'][$key]);
        }
      }
    }
    return $options;
  }

  /**
   * Retrieves the first layout specified by one of the active contexts.
   */
  function get_active_layout() {
    foreach ($this
      ->get_contexts() as $context) {
      $values = $this
        ->fetch_from_context($context);
      if (isset($values['layout'])) {
        return $values['layout'];
      }
    }

    // None of the active contexts specified a layout.
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
context_omega_reaction_omega_layout::get_active_layout function Retrieves the first layout specified by one of the active contexts.
context_omega_reaction_omega_layout::options_form function Options form. Overrides context_reaction_block::options_form
context_omega_reaction_omega_layout::options_form_submit function Override of submit handler. Overrides context_reaction_block::options_form_submit
context_reaction::$description property
context_reaction::$plugin property
context_reaction::$title property
context_reaction::fetch_from_context function Retrieve options from the context provided. 1
context_reaction::get_contexts function Retrieve active contexts that have values for this reaction.
context_reaction::__clone function Clone our references when we're being cloned.
context_reaction::__construct function Constructor. Do not override.
context_reaction_block::block_get_blocks_by_region function Get a renderable array of a region containing all enabled blocks.
context_reaction_block::block_list function An alternative version of block_list() that provides any context enabled blocks.
context_reaction_block::block_sort static function Sort callback.
context_reaction_block::context_block_ajax_rendering_allowed private function Allow modules to selectively allow ajax rendering of a specific block
context_reaction_block::editable_block protected function Add markup for making a block editable.
context_reaction_block::editable_region protected function Add markup for making a region editable.
context_reaction_block::editor_form function Context editor form for blocks. 1
context_reaction_block::editor_form_submit function Submit handler context editor form. 1
context_reaction_block::execute function Execute.
context_reaction_block::get_blocks function Helper function to generate a list of blocks from a specified region. If provided a context object, will generate a full list of blocks for that region distinguishing between system blocks and context-provided blocks.
context_reaction_block::is_editable_check function Determine if there is an active context editor block, and set a flag. We will set a flag so that we can make sure that blocks with empty content have some default content. This is needed so the save of the context inline editor does not remove the…
context_reaction_block::is_editable_region protected function Determine whether inline editing requirements are met and that the current user may edit.
context_reaction_block::is_enabled_region protected function Return a list of enabled regions for which blocks should be built. Split out into a separate method for easy overrides in extending classes. 1
context_reaction_block::json_decode protected function Compatibility wrapper around json_decode().
context_reaction_block::max_block_weight protected function Generate the safe weight range for a block being added to a region such that there are enough potential unique weights to support all blocks.
context_reaction_block::rebuild_needed function Check or set whether a rebuild of the block info cache is needed.
context_reaction_block::render_ajax function Block renderer for AJAX requests. Triggered when $_GET['context_block'] is set. See ->execute() for how this is called.
context_reaction_block::settings_form function Settings form for variables. Overrides context_reaction::settings_form
context_reaction_block::system_region_list protected function Provide caching for system_region_list since it can get called frequently. Evaluate for removal once https://drupal.org/node/1873450 lands or system_region_list is otherwise cached in core