You are here

function node_gallery_upload_image_form in Node Gallery 6.3

Displays the content of the "Upload Images" tab.

Parameters

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

Return value

HTML output.

1 call to node_gallery_upload_image_form()
node_gallery_upload_image_to_new_gallery_form in ./node_gallery.pages.inc
@file Handles displaying of Node gallery pages.
1 string reference to 'node_gallery_upload_image_form'
node_gallery_menu in ./node_gallery.module
Implements hook_menu().

File

./node_gallery.pages.inc, line 50
Handles displaying of Node gallery pages.

Code

function node_gallery_upload_image_form($gallery) {
  global $user;
  if ($gallery->nid > 0) {
    node_gallery_set_user_breadcrumb($gallery->uid, $gallery);
  }
  $relationship = node_gallery_get_relationship($gallery->type);
  if (module_exists('plupload') && variable_get('node_gallery_plupload_integration', TRUE)) {
    $filefield_name = $relationship['image_type'] . ':::' . $relationship['imagefield_name'];
    $options = array(
      'drupal_pluploaded' => TRUE,
      'drupal_gid' => $gallery->nid,
      'drupal_plupload_import_field_type' => $filefield_name,
    );
    $output = '';
    if (!user_access('bulk upload files with plupload')) {
      drupal_set_message(t('You have permissions to view this tab, but not to upload images.  Please inform an administrator that you need the \'bulk upload files with plupload\' permission.'), 'warning');
    }
    else {
      if ($gallery->edit_after_plupload) {
        $settings = array(
          'gid' => $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,
        ), 'setting');
        drupal_add_js(drupal_get_path('module', 'node_gallery') . '/js/ng_plupload.js');
      }
      $output = plupload_upload_page($options);
    }
    return $output;
  }

  // Pull the image type from the relationship, and display it's form:
  $imagetype = $relationship['image_type'];
  $node = new stdClass();
  $node->type = $imagetype;
  $node->uid = $user->uid;
  $node->name = isset($user->name) ? $user->name : '';
  module_load_include('pages.inc', 'node');
  $output = drupal_get_form($imagetype . '_node_form', $node);
  return $output;
}