You are here

function context_reaction_block::editor_form in Context 7.3

Same name and namespace in other branches
  1. 6.3 plugins/context_reaction_block.inc \context_reaction_block::editor_form()
  2. 6 plugins/context_reaction_block.inc \context_reaction_block::editor_form()

Context editor form for blocks.

1 call to context_reaction_block::editor_form()
context_layouts_reaction_block::editor_form in context_layouts/plugins/context_layouts_reaction_block.inc
Override of editor form.
1 method overrides context_reaction_block::editor_form()
context_layouts_reaction_block::editor_form in context_layouts/plugins/context_layouts_reaction_block.inc
Override of editor form.

File

plugins/context_reaction_block.inc, line 121

Class

context_reaction_block
Expose blocks as context reactions.

Code

function editor_form($context) {
  $form = array();
  drupal_add_library('system', 'ui.droppable');
  drupal_add_library('system', 'ui.sortable');
  drupal_add_js(drupal_get_path('module', 'context_ui') . '/json2.js');
  drupal_add_js(drupal_get_path('module', 'context_ui') . '/theme/filter.js');
  drupal_add_js(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.js');
  drupal_add_css(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.css');

  // We might be called multiple times so use a static to ensure this is set just once.
  static $once;
  if (!isset($once)) {
    $settings = array(
      'path' => drupal_is_front_page() ? base_path() : url($_GET['q']),
      'params' => (object) array_diff_key($_GET, array(
        'q' => '',
      )),
      'scriptPlaceholder' => theme('context_block_script_placeholder', array(
        'text' => '',
      )),
    );
    drupal_add_js(array(
      'contextBlockEditor' => $settings,
    ), 'setting');
    $once = TRUE;
  }
  $form['state'] = array(
    '#type' => 'hidden',
    '#attributes' => array(
      'class' => array(
        'context-block-editor-state',
      ),
    ),
  );
  $form['browser'] = array(
    '#markup' => theme('context_block_browser', array(
      'blocks' => $this
        ->get_blocks(NULL, NULL, $this
        ->rebuild_needed()),
      'context' => $context,
    )),
  );
  $this
    ->rebuild_needed(FALSE);
  return $form;
}