You are here

function radioactivity_arbitrary_source_admin_list in Radioactivity 5

1 string reference to 'radioactivity_arbitrary_source_admin_list'
radioactivity_arbitrary_source_menu in plugins/radioactivity_arbitrary_source.module

File

plugins/radioactivity_arbitrary_source.module, line 57

Code

function radioactivity_arbitrary_source_admin_list() {
  global $radioactivity_arbitrary_source_skip_radioactivity_info;
  $radioactivity_arbitrary_source_skip_radioactivity_info = TRUE;
  $sources = _radioactivity_get_arbitrary_sources();
  $info = radioactivity_get_radioactivity_info();
  $form = array();
  foreach (array_keys($info['targets']) as $target) {
    $form[$target] = array(
      '#type' => 'fieldset',
      '#title' => t('Sources for #target', array(
        '#target' => $target,
      )),
      '#description' => t('Configure arbitrary radioactivity energy sources for #target', array(
        '#target' => $target,
      )),
    );
    $rows = array();
    foreach ($info['sources'][$target] as $id => $data) {
      $rows[] = array(
        'data' => array(
          $id,
          $data['title_placeholder'],
          t('Non-configurable'),
        ),
      );
    }
    if (count($sources[$target])) {
      foreach ($sources[$target] as $id => $data) {
        $row = array(
          'data' => array(
            $id,
            $data['title_placeholder'],
            l(t('Edit'), 'admin/settings/radioactivity/arbitrary_source/' . $target . '/' . $id) . ' ' . l(t('Delete'), 'admin/settings/radioactivity/arbitrary_source_delete/' . $target . '/' . $id),
          ),
        );

        // check for conflicting row
        if (isset($info['sources'][$target][$id])) {
          $row['class'] = 'error';
          drupal_set_message(t('Conflicting source definition detected. Please remove arbitrary source %s for target %t. ' . 'It is already provided by another plugin.', array(
            '%s' => $id,
            '%t' => $target,
          )), 'error');
        }
        $rows[] = $row;
      }
    }
    $table = theme('table', array(
      t('Source identifier'),
      t('Source label'),
      t('Actions'),
    ), $rows);
    $form[$target]['arb_sources'] = array(
      '#value' => $table,
    );
    if (count($sources[$target]) == 0) {
      $form[$target]['no_sources'] = array(
        '#type' => 'item',
        '#value' => t('No arbitrary sources configured.'),
      );
    }
    $form[$target]['new_source'] = array(
      '#type' => 'item',
      '#value' => l(t('New source'), 'admin/settings/radioactivity/arbitrary_source/' . $target),
    );
  }
  return $form;
}