You are here

function quickupdate_form_update_manager_update_form_alter in Quick update 7

Same name and namespace in other branches
  1. 8 quickupdate.module \quickupdate_form_update_manager_update_form_alter()

Implements hook_form_FORM_ID_alter().

File

./quickupdate.module, line 60
Primarily Drupal hooks and global API functions.

Code

function quickupdate_form_update_manager_update_form_alter(&$form, &$form_state, $form_id) {

  // Loads all the missing dependency projects.
  $dependencies = quickupdate_load_missing_dependencies();

  // Adds the "missing_dependency_projects" form item.
  if (count($dependencies) > 0) {
    $headers = array(
      'title' => array(
        'data' => t('Name'),
        'class' => array(
          'update-project-name',
        ),
      ),
      'installed_version' => t('Installed version'),
      'recommended_version' => t('Recommended version'),
    );
    $form['missing_dependency_projects'] = array(
      '#type' => 'tableselect',
      '#header' => $headers,
      '#options' => $dependencies,
      '#prefix' => '<h2>' . t('Missing dependency projects') . '</h2>',
      '#weight' => 20,
      '#suffix' => t("Some modules may have multiple level dependencies, so you should run the update process multiple times until there is no more missing dependency projects."),
    );
  }

  // Adds the "other_projects" form item.
  // It allows you to install multiple projects at a time.
  $form['search_project'] = array(
    '#type' => 'textfield',
    '#default_value' => "",
    '#weight' => 21.0,
    '#autocomplete_path' => 'quickupdate/autocomplete/search_projects',
    '#prefix' => '<h2>' . t('Install new projects') . '</h2><div class="container-inline">',
    '#attributes' => array(
      'placeholder' => t('Search the most installed projects.'),
    ),
  );
  $form['add_project'] = array(
    '#type' => 'button',
    '#default_value' => t('Add'),
    '#weight' => 21.1,
  );
  $form['view_project'] = array(
    '#type' => 'button',
    '#default_value' => t('View'),
    '#weight' => 21.2,
  );
  $form['clear_project'] = array(
    '#type' => 'button',
    '#default_value' => t('Clear'),
    '#weight' => 21.3,
    '#suffix' => '</div>',
  );
  $form['other_projects'] = array(
    '#type' => 'textarea',
    '#rows' => 10,
    '#default_value' => "",
    '#weight' => 22,
    '#description' => t('Enter the projects names that you want to install. One project per line.'),
  );
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'quickupdate') . '/js/quickupdate.js',
  );

  // Uses validation function 'quickupdate_manager_update_form_validate'
  // instead of 'update_manager_update_form_validate'.
  $form['#validate'] = array(
    'quickupdate_manager_update_form_validate',
  );

  // Uses submit function 'quickupdate_manager_update_form_submit'
  // instead of 'update_manager_update_form_submit'.
  $form['#submit'] = array(
    'quickupdate_manager_update_form_submit',
  );

  // Always show the 'Download these updates' button.
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Download these updates'),
  );
}