You are here

function bean_admin_ui_admin_page in Bean (for Drupal 7) 7

Main page callback on the bean type

1 string reference to 'bean_admin_ui_admin_page'
bean_admin_ui_menu in bean_admin_ui/bean_admin_ui.module
Implements hook_menu().

File

bean_admin_ui/bean_admin_ui.admin.inc, line 11
Bean Admin Page

Code

function bean_admin_ui_admin_page() {
  $field_ui = module_exists('field_ui');
  $rows = array();
  $i = 0;
  foreach (bean_get_types() as $bean_type) {
    $row = array();
    $row[] = array(
      'data' => check_plain($bean_type
        ->getLabel()),
    );
    if (method_exists($bean_type, 'getExportStatus')) {
      $export_status = $bean_type
        ->getExportStatus();
    }
    else {
      $export_status = t('Normal');
    }
    $row[] = array(
      'data' => $export_status,
    );

    // Edit and delete buttons
    if ($bean_type
      ->isEditable()) {
      $row[] = array(
        'data' => l(t('Edit'), 'admin/structure/block-types/manage/' . $bean_type
          ->buildURL() . '/edit'),
      );
      switch ($export_status) {
        case t('Normal'):
          $row[] = array(
            'data' => l(t('Delete'), 'admin/structure/block-types/manage/' . $bean_type
              ->buildURL() . '/delete'),
          );
          break;
        case t('Overridden'):
          $row[] = array(
            'data' => l(t('Revert'), 'admin/structure/block-types/manage/' . $bean_type
              ->buildURL() . '/revert'),
          );
          break;
        case t('Default'):
          $row[] = array();
          break;
      }
    }
    else {

      // For the operations
      $row[] = array();
      $row[] = array();
    }
    if ($field_ui) {

      // Manage fields.
      $row[] = array(
        'data' => l(t('manage fields'), 'admin/structure/block-types/manage/' . $bean_type
          ->buildURL() . '/fields'),
      );

      // Display fields.
      $row[] = array(
        'data' => l(t('manage display'), 'admin/structure/block-types/manage/' . $bean_type
          ->buildURL() . '/display'),
      );
    }

    //creative way to setup sorting rows; add number to prevent dual keys
    $rows[str_replace(' ', '', $bean_type
      ->getLabel()) . '_' . $i] = $row;
  }
  ksort($rows);
  $header = array(
    t('Name'),
    t('Status'),
    array(
      'data' => t('Operations'),
      'colspan' => $field_ui ? '4' : '2',
    ),
  );
  $build['bean_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('There are no Block Types Available'),
  );
  return $build;
}