You are here

function node_gallery_api_upload_items_form in Node Gallery 7

Displays the content of the "Upload Items" tab.

Parameters

object $gallery: A populated node gallery object which will house the items.

Return value

string HTML output.

1 string reference to 'node_gallery_api_upload_items_form'
node_gallery_api_menu in ./node_gallery_api.module
Implements hook_menu().

File

./node_gallery_api.pages.inc, line 673
Node Gallery module.

Code

function node_gallery_api_upload_items_form($gallery, $item_type = NULL) {
  global $user;
  if ($gallery->nid > 0) {

    // node_gallery_set_user_breadcrumb($gallery->uid, $gallery);
  }
  $relationship_type = node_gallery_api_get_relationship_type($gallery->type);
  if (empty($item_type)) {
    $item_type = $relationship_type->item_types[0];
  }
  if (module_exists('plupload') && variable_get('node_gallery_api_plupload_integration', TRUE)) {
    if (!empty($gallery->edit_after_plupload)) {
      $settings = array(
        'ngid' => $gallery->nid,
        'galleryType' => $gallery->type,
        'url_prefix' => variable_get('clean_url', 0) > 0 ? '' : '?q=',
        'token' => drupal_get_token('node_gallery_plupload'),
      );
      drupal_add_js(array(
        'node_gallery' => $settings,
      ), array(
        'type' => 'setting',
        'scope' => JS_DEFAULT,
      ));
      drupal_add_js(drupal_get_path('module', 'node_gallery') . '/js/ng_plupload.js');
    }
    $output = drupal_get_form('node_gallery_api_plupload_form', $relationship_type, $gallery->nid, $item_type);
    return $output;
  }

  // Pull the image type from the relationship, and display it's form:
  $node = new stdClass();
  $node->type = $item_type;
  $node->uid = $user->uid;
  $node->name = isset($user->name) ? $user->name : '';
  $node->language = LANGUAGE_NONE;
  $node->node_gallery_target_id = $gallery->nid;
  $node->node_gallery_field_name = 'node_gallery_ref_' . $relationship_type->id;
  $form_state['build_info']['args'][] = $node;
  form_load_include($form_state, 'inc', 'node', 'node.pages');
  $form = drupal_build_form($item_type . '_node_form', $form_state);
  return $form;
}