You are here

function node_gallery_api_plupload_form in Node Gallery 7

Plupload integration form.

1 string reference to 'node_gallery_api_plupload_form'
node_gallery_api_upload_items_form in ./node_gallery_api.pages.inc
Displays the content of the "Upload Items" tab.

File

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

Code

function node_gallery_api_plupload_form($form, $form_state, $relationship_type, $ngid, $item_type) {
  $instance = field_info_instance('node', $relationship_type->filefield_name, $item_type);
  $allowed_extensions = !empty($instance['settings']['file_extensions']) ? $instance['settings']['file_extensions'] : 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
  $file_max_size = !empty($instance['settings']['max_filesize']) ? parse_size($instance['settings']['max_filesize']) : file_upload_max_size();
  $form['#attributes'] = array(
    'enctype' => "multipart/form-data",
  );
  $form['upload'] = array(
    '#type' => 'plupload',
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        $allowed_extensions,
      ),
      'file_validate_size' => array(
        $file_max_size,
      ),
    ),
    '#plupload_settings' => array(
      'max_file_size' => $file_max_size,
      'url' => url('node-gallery/json/item/create/' . $relationship_type->id . '/' . $ngid . '/' . $item_type . '/' . drupal_get_token('node_gallery_api_item_create')),
    ),
  );
  $form['relationship_type'] = array(
    '#type' => 'value',
    '#value' => $relationship_type,
  );
  $form['#attached']['js'][] = drupal_get_path('module', 'node_gallery_api') . '/js/ng_plupload.js';
  return $form;
}