1 contact.admin.inc contact_category_list($form, $form_state)

Page callback: Lists contact categories.

See also

contact_menu()

File

core/modules/contact/contact.admin.inc, line 176
Admin page callbacks for the Contact module.

Code

function contact_category_list($form, $form_state) {
  $form['help'] = array(
    '#type' => 'markup',
    '#markup' => t('Configure the categories shown in the site-wide contact form available at <a href="!url">!url</a>. All categories are shown in a select list on the contact form, which will send to different addresses when selected.', array('!url' => url('contact'))),
    '#weight' => -20,
  );

  $config_data = contact_config_data();
  $default_category = $config_data['contact_default_category'];
  $categories = (array) $config_data['categories'];

  $form['categories'] = array(
    '#theme' => 'contact_category_list_table',
    '#tree' => TRUE,
  );

  // Loop through the categories and add them to the table.
  foreach ($categories as $cat) {
    $cid = $cat['cid'];

    $links = array();
    $links['configure'] = array(
      'title' => t('Configure'),
      'href' => 'admin/structure/contact/configure/' . $cid,
    );
    $links['delete'] = array(
      'title' => t('Delete'),
      'href' => 'admin/structure/contact/delete/' . $cid,
    );

    $form['categories'][$cid]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight for @title', array('@title' => $cat['category'])),
      '#title_display' => 'invisible',
      '#default_value' => $cat['weight'],
      '#delta' => max(10, count($categories)),
    );
    $form['categories'][$cid]['name'] = array(
      '#markup' => check_plain($cat['category']),
    );
    $recipients = explode(',', check_plain($cat['recipients']));
    $form['categories'][$cid]['recipients'] = array(
      '#markup' => theme('item_list', array('items' => $recipients)),
    );
    $form['categories'][$cid]['default'] = array(
      '#markup' => ($cid == $default_category) ? t('Yes') : t('No'),
    );
    $form['categories'][$cid]['operations'] = array(
      '#type' => 'operations',
      '#links' => $links,
    );
  }

  $form['actions'] = array(
    '#type' => 'actions',
    '#access' => count($categories) > 1,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save order')
  );

  return $form;
}