You are here

function custom_formatters_overview in Custom Formatters 6

@file Contains administration functions for the Custom Formatters module.

1 string reference to 'custom_formatters_overview'
custom_formatters_menu in ./custom_formatters.module
Implements hook_menu().

File

./custom_formatters.admin.inc, line 7
Contains administration functions for the Custom Formatters module.

Code

function custom_formatters_overview($form_state) {
  if (isset($form_state['values']['operation'])) {
    switch ($form_state['values']['operation']) {
      case 'delete':
        return custom_formatters_bulk_delete_confirm($form_state, array_filter($form_state['values']['formatters']));
      case 'convert':
        return custom_formatters_bulk_convert_confirm($form_state, array_filter($form_state['values']['formatters']));
      case 'export':
        drupal_set_title(t('Bulk export'));
        return custom_formatters_formatter_export_form($form_state, array_filter($form_state['values']['formatters']));
    }
  }
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => array(
      'export' => t('Export'),
      'convert' => t('Convert'),
      'delete' => t('Delete'),
    ),
    '#default_value' => 'approve',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#submit' => array(
      'custom_formatters_bulk_submit',
    ),
  );
  $destination = drupal_get_destination();
  $formatters = array();
  foreach (custom_formatters_formatters(FALSE, 25) as $formatter) {
    $operations = array();
    if ($formatter->status) {
      $operations[] = l(t('Edit'), 'admin/build/formatters/edit/' . $formatter->name, array(
        'query' => $destination,
      ));
      $operations[] = $formatter->source == 'module' ? t('Revert') : l(isset($formatter->override) ? t('Revert') : t('Delete'), 'admin/build/formatters/delete/' . $formatter->name, array(
        'query' => $destination,
      ));
      $operations[] = l(t('Clone'), 'admin/build/formatters/clone/' . $formatter->name, array(
        'query' => $destination,
      ));
      $operations[] = l(t('Export'), 'admin/build/formatters/export/' . $formatter->name, array(
        'query' => $destination,
      ));
      $operations[] = $formatter->mode == 'basic' ? l(t('Convert'), 'admin/build/formatters/convert/' . $formatter->name, array(
        'query' => $destination,
      )) : t('Convert');
      $operations[] = l(t('Disable'), 'admin/build/formatters/status/' . $formatter->name, array(
        'query' => $destination,
      ));
    }
    else {
      $operations[] = l(t('Enable'), 'admin/build/formatters/status/' . $formatter->name, array(
        'query' => $destination,
      ));
    }
    $formatters[$formatter->name] = '';
    $form['label'][$formatter->name] = array(
      '#value' => l($formatter->label, 'admin/build/formatters/edit/' . $formatter->name, array(
        'query' => $destination,
      )),
    );
    $form['mode'][$formatter->name] = array(
      '#value' => $formatter->mode,
    );
    $form['fields'][$formatter->name] = array(
      '#value' => implode(', ', unserialize($formatter->field_types)),
    );
    $form['operations'][$formatter->name] = array(
      '#value' => implode('&nbsp;&nbsp;&nbsp;&nbsp;', $operations),
    );
  }
  $form['formatters'] = array(
    '#type' => 'checkboxes',
    '#options' => $formatters,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 25),
  );
  return $form;
}