You are here

function photos_swfu_form in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 photos_swfu/photos_swfu.module \photos_swfu_form()

Build SWFU form.

1 call to photos_swfu_form()
photos_swfu_form_alter in photos_swfu/photos_swfu.module
Implements hook_form_alter().

File

photos_swfu/photos_swfu.module, line 102

Code

function photos_swfu_form($pid = 0, $nid = 0) {
  global $user, $language;
  $swfu_switch = isset($_SESSION['photos_swfu_switch']) ? $_SESSION['photos_swfu_switch'] : 0;
  if ($swfu_switch != 1) {
    drupal_add_css(drupal_get_path('module', 'photos_swfu') . '/photos_swfu.css');
    drupal_add_js(drupal_get_path('module', 'photos_swfu') . '/fileprogress.js');
    drupal_add_js(drupal_get_path('module', 'photos_swfu') . '/handlers.js');
    $v = array();
    $op = array();
    $op['query']['uid'] = $user->uid;
    if ($nid) {
      $op['query']['nid'] = $nid;
    }
    $v['url'] = url('photos_swfu/upload/' . $pid, $op);
    $path = drupal_get_path('module', 'photos_swfu');
    if (is_file($path . '/button/' . $language->language . '_61x22.png')) {
      $v['image'] = base_path() . $path . '/button/' . $language->language . '_61x22.png';
    }
    else {
      $v['image'] = base_path() . $path . '/XPButtonUploadText_61x22.png';
    }
    if (($library = libraries_load('swfupload')) && !empty($library['loaded'])) {

      // Avoid conflict with libraries module and swfupload module.
      drupal_add_js($library['library path'] . '/plugins/swfupload.queue.js');
      $v['swf'] = base_path() . $library['library path'] . '/Flash/swfupload.swf';
    }
    else {
      if ($user->uid == 1) {
        drupal_set_message(t('Please add swfupload to the sites/all/libraries directory.'), 'error');
      }
    }
    if (arg(1) == 'quote') {
      $v['href'] = url($_GET['q'], array(
        'query' => array(
          'type' => 'upload',
        ),
      ));
    }
    else {
      $v['href'] = url($_GET['q'], array(
        'query' => array(
          'type' => 'tx',
        ),
      ));
    }
    if ($user->uid == 1) {
      $v['max_file_size'] = '200';
      $v['num_uploads'] = '0';
    }
    else {

      // @todo set global limits?
      // $limits = _upload_file_limits($user);
      $v['max_file_size'] = '200';

      // $limits['file_size'] / 1024 / 1024;
      $v['num_uploads'] = variable_get('photos_swfu_num', 50);
    }
    $form['new']['swfu'] = array(
      '#markup' => theme('photos_swfu_style', array(
        'v' => $v,
      )),
      '#weight' => -1,
    );
    $svluae = t('Click here to switch to the classic upload form.');
  }
  else {
    $svluae = t('Click here to switch back to the flash form.');
  }
  $form['button']['#weight'] = -10;
  $form['button']['switch'] = array(
    '#type' => 'submit',
    '#value' => $svluae,
    '#submit' => array(
      '_photos_swfu_switch',
    ),
    '#weight' => -20,
  );
  return $form;
}