You are here

function _get_ga_form in Gallery Assist 6

1 call to _get_ga_form()
gallery_assist_form_alter in ./gallery_assist.module
Implementation of hook_form_alter().

File

./gallery_assist.module, line 1002
Drupal content type with gallery functionality.

Code

function _get_ga_form(&$form) {
  $node = $form['#node'];
  if ($node->type == 'book' && arg(2) == 'outline') {
    return;
  }
  $data = variable_get('gallery_assist_' . $node->type . '_data', FALSE);
  if (!isset($node->gallconf) || empty($node->gallconf)) {
    $additions = gallery_assist_load($node);
    if (!empty($additions)) {
      foreach ($additions as $key => $value) {
        $node->{$key} = $value;
      }
    }
  }
  $form += gallery_assist_form_help_links($node);
  $form['ref'] = array(
    '#type' => 'hidden',
    '#value' => $node->ref ? $node->ref : $node->nid,
  );
  $form['gref'] = array(
    '#type' => 'hidden',
    '#value' => $node->gref ? $node->gref : $node->gid,
  );

  // Note on the order of the process of "create gallery assist node"
  $help_path_tail = $node->type == 'gallery_assist' ? '' : '_' . $node->type;
  if (arg(1) == 'add') {
    global $base_url;
    $this['help']['layout'] = array(
      'module' => 'gallery_assist',
      'help_link' => 'why-save-before-upload',
      'text' => t('This article must be saved FIRST before you can add IMAGES to the gallery. Read more about in the <a href="@help_link">help</a>.', array(
        '@help_link' => url($base_url . '/gallery_assist' . $help_path_tail . '/help#ga_why'),
      )),
    );
    $form['#prefix'] = variable_get("hide_node_first_notice_for_{$node->type}", FALSE) ? '' : '<div id="gallery-assist-node-info">' . gallery_assist_advanced_help_builder($this['help']['layout']) . '</div>';
  }
  if (isset($node->nid) && variable_get('gallery_assist_' . $node->type, 0) == 1) {
    $this['help']['layout'] = array(
      'module' => 'gallery_assist',
      'help_link' => 'settings-to-this-gallery',
      'text' => t('Read the short help in case you are not secure by this settings.'),
    );
    $ga_ui_settings = variable_get("gallery_assist_ui_settings", array());
    if (!isset($ga_ui_settings[$node->type]) || $ga_ui_settings[$node->type] == 0) {
      $form['gallery_assist_settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('Gallery Assist (GA) settings'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => $form['title']['#weight'] + 0.5,
      );
      module_load_include('inc', 'gallery_assist', 'gallery_assist_node_settings');
      $form['gallery_assist_settings']['wrapper'] = gallery_assist_settings_tothis_node($node, $data);
      if (arg(2) == 'edit') {
        if (isset($_GET['page']) && $_GET['page'] > 0) {
          $collapsed = FALSE;
        }
        else {
          $collapsed = count($node->gallitems) > 5 ? TRUE : FALSE;
        }
      }
      $node->check_all_links = count($node->gallitems) > 1 ? t('<span class="ga-check-all description">@check_all</span> | <span class="ga-uncheck-all description">@uncheck_all</span>', array(
        '@check_all' => t('check all'),
        '@uncheck_all' => t('uncheck all'),
      )) : '';

      // Upload process form section.
      $form['gallery_assist_item'] = array(
        '#type' => 'fieldset',
        '#title' => t('Gallery Assist (GA): Add and edit items') . ' (' . $node->gallconf[$node->type]['ga_counter'] . ')',
        '#collapsible' => TRUE,
        '#collapsed' => $collapsed,
        '#prefix' => '<div class="gallery_assist_list">',
        '#suffix' => '</div>',
        '#weight' => $form['title']['#weight'] + 1,
        '#description' => t('Click Update to upload a new file or to save your changes in this section.<br />') . $node->check_all_links,
      );
      $form['has_cover'] = array(
        '#type' => 'hidden',
        '#value' => $node->has_cover,
      );
      $form['ga_save_caller'] = array(
        '#type' => 'hidden',
        '#value' => 'node_edit',
      );

      // 1- node-edit.
      $form['gallery_assist_item']['ga_save_caller'] = array(
        '#type' => 'hidden',
        '#value' => 1,
      );

      // Wrapper for fieldset contents (used by ahah.js).
      $form['gallery_assist_item']['wrapper'] = array(
        '#prefix' => '<div id="gallery-assist-list-wrapper">',
        '#suffix' => '</div>',
      );

      // It sends the current user as a reference, if administrators make
      // changes in the author information of the node.
      $form['gallery_assist_item']['current_owner'] = array(
        '#type' => 'value',
        '#value' => $node->uid,
      );
      $form['gallery_assist_item']['wrapper'] += _gallery_assist_form($node);
      $form['#attributes']['enctype'] = 'multipart/form-data';
      $form['#submit'][] = 'gallery_assist_form_submit';

      // Add a checkbox to lock or unlock the gallery.
      $form['ga_lock'] = array(
        '#type' => 'fieldset',
        '#access' => $node->gallconf[$node->type]['ga_counter'] > 100 ? TRUE : FALSE,
        '#weight' => 3000,
      );
      $form['ga_lock']['gallery_assist_lockked'] = array(
        '#type' => 'checkbox',
        '#title' => t('One time lock'),
        '#default_value' => FALSE,
        '#description' => t('Enable this parameter to avoid over head or long wait time in case your changes fields that are not part of the gallery. By enabled is all the data from gallery items excluded from the save process.'),
      );
    }
  }
  return $form;
}