You are here

function media_gallery_block_configure in Media Gallery 7

Same name and namespace in other branches
  1. 7.2 media_gallery.module \media_gallery_block_configure()

Implements hook_block_configure().

File

./media_gallery.module, line 686

Code

function media_gallery_block_configure($delta = '') {

  // Duplicate the form for configuring media gallery node fields, including
  // our module's custom alterations. We can't use drupal_get_form() here
  // because that will mess up the form submission, so for now we have to live
  // without getting any other module's alterations to this part of the node
  // form.
  $node = node_load($delta);
  $form = array();
  $form_state = array();
  field_attach_form('node', $node, $form, $form_state, $node->language);
  media_gallery_form_media_gallery_node_form_alter($form, $form_state);

  // Pull out only the parts of the node form that allow configuration of the
  // block settings; these are the ones we want to display.
  $block_settings = array(
    'block' => $form['block'],
  );

  // Store a record of all node fields that we will need to save when
  // hook_block_save() is called.
  $block_settings['block']['media_gallery_block_fields'] = array(
    '#type' => 'value',
    '#value' => element_children($block_settings['block']),
  );

  // Don't allow people to destroy the block itself from the block
  // configuration page.
  $block_settings['block']['media_gallery_expose_block']['#access'] = FALSE;

  // Customize the fieldset display.
  $block_settings['block']['#collapsible'] = FALSE;
  $block_settings['block']['#title'] = t('Block settings');
  unset($block_settings['block']['#weight']);

  // Add the necessary attached JS and CSS.
  _media_gallery_attach_form_resources($block_settings['block']);
  return $block_settings;
}