You are here

function plupload_upload_page in Plupload integration 6

Page callback for the bulk uploader.

1 string reference to 'plupload_upload_page'
plupload_menu in ./plupload.module
Implementation of hook_menu().

File

./plupload.module, line 84

Code

function plupload_upload_page($options = array()) {
  $path = plupload_library_path();

  // Plupload changed their distro file structure starting with version 1.4.3, but the github repo still uses the old structure
  // Also, instead of including separate minified js files, all js files in a release are minified.  Only github source is non-minified
  if (file_exists($path . '/src/javascript')) {
    $js_dir = $path . '/src/javascript';
    $queue_dir = $js_dir;
    $css_file = $path . '/examples/css/plupload.queue.css';
  }
  elseif (file_exists($path . '/js')) {
    $js_dir = $path . '/js';
    $queue_dir = $js_dir . '/jquery.plupload.queue';
    $css_file = $queue_dir . '/css/jquery.plupload.queue.css';
  }
  else {
    drupal_set_message(t('Plupload library directory exists at %path, but no src/javascript or js directories were found within it.', array(
      '%path' => $path,
    )), 'error');
  }
  drupal_add_js($js_dir . '/plupload.js');
  drupal_add_js($js_dir . '/plupload.html5.js');
  drupal_add_js($queue_dir . '/jquery.plupload.queue.js');
  drupal_add_js($js_dir . '/plupload.flash.js');
  drupal_add_css($css_file);
  $query_string = $_GET;
  unset($query_string['q']);

  // In case we're not being called via hook_menu, we allow other contrib modules to add query string options
  $query_string += $options;

  // Let the options array override the variable if it's set
  if (isset($options['drupal_plupload_import_field_type'])) {
    $plupload_import_field_type = $options['drupal_plupload_import_field_type'];
  }
  else {
    $plupload_import_field_type = variable_get('plupload_import_field_type', 'photo:::field_photo');
  }

  // Get the field and its validators so we can build our extension list.
  list($type, $field_name) = explode(':::', $plupload_import_field_type);
  $field = content_fields($field_name, $type);
  $validators = imagefield_widget_upload_validators($field);
  $extensions = str_replace(' ', ',', $validators['filefield_validate_extensions'][0]);
  $url = url('plupload-pernode', array(
    'query' => $query_string,
  ));
  $swfurl = url('') . $js_dir . '/plupload.flash.swf';
  $settings = array();
  $settings['plupload'] = array(
    'url' => $url,
    'swfurl' => $swfurl,
    'extensions' => $extensions,
  );
  drupal_add_js($settings, 'setting');
  $output .= theme('plupload_uploader');
  return $output;
}