You are here

function gathercontent_project_form in GatherContent 7.2

Form constructor for selecting project.

1 string reference to 'gathercontent_project_form'
gathercontent_menu in ./gathercontent.module
Implements hook_menu().

File

includes/project.inc, line 10
Contains project select form.

Code

function gathercontent_project_form($form, &$form_state) {
  gathercontent_check_step('projects');
  $obj = gathercontent_get_obj();
  $obj
    ->getProjects();
  if (isset($obj->data['projects']) && count($obj->data['projects']) > 0) {
    $options = array();
    $default = NULL;
    foreach ($obj->data['projects'] as $id => $info) {
      if (is_null($default)) {
        $default = $id;
      }
      $options[$id] = $info['name'] . ' &mdash; <span class="page-count">' . $info['page_count'] . ' ' . $info['word'] . '</span>';
    }
    $form['header'] = array(
      '#prefix' => '<div class="gc_cf">',
      '#markup' => '<h2 class="gc_left">' . t('Choose a project to import content from') . '</h2>',
    );
    $form['link'] = array(
      '#type' => 'link',
      '#title' => t('Account settings'),
      '#href' => 'admin/config/content/gathercontent/login',
      '#prefix' => '<div class="gc_right">',
      '#suffix' => '</div></div>',
    );
    $form['gathercontent_project_id'] = array(
      '#type' => 'radios',
      '#default_value' => variable_get('gathercontent_project_id', $default),
      '#options' => $options,
      '#required' => TRUE,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Import content'),
    );
  }
  else {
    drupal_set_message(t('No projects found'), 'error');
  }
  return $form;
}