You are here

function paragraphs_admin_bundle_overview in Paragraphs 7

Page callback to show the bundle overview page.

Return value

null|string Rendered table of bundles.

Throws

Exception

1 string reference to 'paragraphs_admin_bundle_overview'
paragraphs_menu in ./paragraphs.module
Implements hook_menu().

File

./paragraphs.admin.inc, line 16
Admin functions for the paragraphs module.

Code

function paragraphs_admin_bundle_overview() {
  $page = array();
  $bundles = paragraphs_bundle_load();
  $field_ui = module_exists('field_ui');
  $header = array(
    t('Bundle name'),
    array(
      'data' => t('Operations'),
      'colspan' => $field_ui ? '4' : '2',
    ),
  );
  $rows = array();
  foreach ($bundles as $bundle) {
    $type_url_str = strtr($bundle->bundle, array(
      '_' => '-',
    ));
    $row = array(
      theme('paragraphs_admin_overview', array(
        'bundle' => $bundle,
      )),
    );

    // Edit bundle.
    $row[] = array(
      'data' => l(t('edit'), 'admin/structure/paragraphs/' . $type_url_str . '/edit'),
    );
    if ($field_ui) {

      // Manage fields.
      $row[] = array(
        'data' => l(t('manage fields'), 'admin/structure/paragraphs/' . $type_url_str . '/fields'),
      );

      // Display fields.
      $row[] = array(
        'data' => l(t('manage display'), 'admin/structure/paragraphs/' . $type_url_str . '/display'),
      );
    }

    // Delete bundle.
    $row[] = array(
      'data' => l(t('delete'), 'admin/structure/paragraphs/' . $type_url_str . '/delete'),
    );
    $rows[$bundle->bundle] = $row;
  }

  // Sort rows by bundle.
  ksort($rows);

  // Render paragraphs bundle table.
  $page['paragraphs_bundle_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No paragraph bundles have been defined yet.'),
  );
  return $page;
}