You are here

function flag_admin_listing in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag.admin.inc \flag_admin_listing()
  2. 7.2 includes/flag.admin.inc \flag_admin_listing()

A form for ordering the weights of all the active flags in the system.

1 string reference to 'flag_admin_listing'
flag_admin_page in includes/flag.admin.inc
Flag administration page. Display a list of existing flags.

File

includes/flag.admin.inc, line 21
Contains administrative pages for creating, editing, and deleting flags.

Code

function flag_admin_listing(&$form_state, $flags) {
  $form['#flags'] = $flags;
  $form['#tree'] = TRUE;
  foreach ($flags as $flag) {
    $form['flags'][$flag->name]['weight'] = array(
      '#type' => 'weight',
      '#delta' => count($flags) + 5,
      '#default_value' => $flag->weight,
      '#attributes' => array(
        'class' => 'flag-weight',
      ),
    );
  }
  if (count($flags) == 1) {

    // Don't show weights with only one flag.
    unset($form['flags'][$flag->name]['weight']);
  }
  else {
    if (count($flags) > 1) {

      // Only show the form button if there are several flags.
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Save flag order'),
      );
    }
  }
  return $form;
}