You are here

function boxes_admin_ui_admin_page in Boxes 7.2

Main page callback on the box type

1 string reference to 'boxes_admin_ui_admin_page'
boxes_admin_ui_menu in boxes_admin_ui/boxes_admin_ui.module
Implements hook_menu().

File

boxes_admin_ui/boxes_admin_ui.admin.inc, line 11
Boxes Admin Page

Code

function boxes_admin_ui_admin_page() {
  $field_ui = module_exists('field_ui');
  $rows = array();
  $i = 0;
  foreach (boxes_get_types() as $box_type) {
    $row = array();
    $row[] = array(
      'data' => $box_type
        ->getLabel(),
    );
    if (method_exists($box_type, 'getExportStatus')) {
      $export_status = $box_type
        ->getExportStatus();
    }
    else {
      $export_status = 'Normal';
    }
    $row[] = array(
      'data' => $export_status,
    );

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

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

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

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