You are here

function data_ui_manage in Data 7

Same name and namespace in other branches
  1. 6 data_ui/data_ui.admin.inc \data_ui_manage()

Main page for data table management.

1 string reference to 'data_ui_manage'
data_ui_menu in data_ui/data_ui.module
Implements hook_menu().

File

data_ui/data_ui.admin.inc, line 36
Admin UI functions.

Code

function data_ui_manage() {
  $tables = data_get_all_tables();
  $rows = array();
  foreach ($tables as $table) {

    // Build operations depending on configuration status.
    $operations = array();
    if ($table
      ->get('export_type') == EXPORT_IN_CODE) {
      $status = t('Default');
      $operations[] = l(t('Override'), 'admin/structure/data/edit/' . $table
        ->get('name'));
    }
    elseif ($table
      ->get('export_type') == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
      $status = t('Overridden');
      $operations[] = l(t('Edit'), 'admin/structure/data/edit/' . $table
        ->get('name'));
      $operations[] = l(t('Revert'), 'admin/structure/data/revert/' . $table
        ->get('name'));
    }
    else {
      $status = t('Normal');
      $operations[] = l(t('Edit'), 'admin/structure/data/edit/' . $table
        ->get('name'));
      $operations[] = l(t('Disown'), 'admin/structure/data/disown/' . $table
        ->get('name'));
      $operations[] = l(t('Drop'), 'admin/structure/data/drop/' . $table
        ->get('name'));
    }
    if (module_exists('ctools')) {
      $operations[] = l(t('Export'), 'admin/structure/data/export/' . $table
        ->get('name'));
    }
    if (module_exists('views')) {

      // The existence of a path serves as a test that a view is provided.
      $path = data_ui_get_default_path($table
        ->get('name'));
      if ($path) {
        $operations[] = l(t('View records'), 'admin/content/data/view/' . $table
          ->get('name'));
        if (user_access('administer views')) {
          $operations[] = l(t('Edit view'), 'admin/structure/views/view/' . $table
            ->get('name') . '/edit');
        }
      }
    }
    $row = array();
    $row[] = check_plain($table
      ->get('title'));
    $row[] = check_plain($table
      ->get('name'));
    $row[] = $status;
    $row[] = implode(' | ', $operations);
    $rows[] = $row;
  }
  $rows[] = array(
    l(t('Create new table'), 'admin/structure/data/create'),
    ' ',
    ' ',
    ' ',
  );
  $header = array(
    t('Title'),
    t('Name'),
    t('Status'),
    t('Operations'),
  );
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}