You are here

function media_gallery_media_page_multiedit in Media Gallery 7

Same name and namespace in other branches
  1. 7.2 media_gallery.pages.inc \media_gallery_media_page_multiedit()

Menu callback; presents the Media multiedit form in the context of a gallery.

1 string reference to 'media_gallery_media_page_multiedit'
media_gallery_menu in ./media_gallery.module
Implements hook_menu().

File

./media_gallery.pages.inc, line 392
Common pages for the Media Gallery module.

Code

function media_gallery_media_page_multiedit($node) {

  // Determine the media entities to edit.
  $columns = $node->media_gallery_columns[LANGUAGE_NONE][0]['value'];
  $rows = $node->media_gallery_rows[LANGUAGE_NONE][0]['value'];
  $number_per_page = $columns * $rows;
  $current_page = isset($_GET['page']) ? $_GET['page'] : 0;
  $items = array_slice($node->media_gallery_media[LANGUAGE_NONE], $current_page * $number_per_page, $number_per_page);
  $fids = array();
  foreach ($items as $item) {
    $fids[] = $item['fid'];
  }
  $files = file_load_multiple($fids);

  // Load the Media module include file containing the form callback.
  // @todo To support AJAX enabled widgets within the form, we need to also add
  //   media.pages.inc to $form_state['build_info']['files']['menu']. Figure out
  //   how to integrate that properly with the Multiform module.
  module_load_include('inc', 'media', 'includes/media.pages');

  // Build and process the form.
  $form = media_page_multiedit($files);

  // Override the page title set by media_page_multiedit() and return the form.
  drupal_set_title(t('<em>Edit media for</em> @title', array(
    '@type' => $node->type,
    '@title' => $node->title,
  )), PASS_THROUGH);
  return $form;
}