You are here

function flag_admin_listing in Flag 7.3

Same name and namespace in other branches
  1. 6.2 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 25
Contains administrative pages for creating, editing, and deleting flags.

Code

function flag_admin_listing($form, &$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' => array(
          'flag-weight',
        ),
      ),
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  if (count($flags) == 1) {

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

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