You are here

function spaces_ui_features in Spaces 5.2

Menu page callback that shows a listing of spaces features.

1 string reference to 'spaces_ui_features'
spaces_ui_menu in ./spaces_ui.module
Implementation of hook_menu().

File

./spaces_ui.module, line 235

Code

function spaces_ui_features() {
  drupal_set_title(t('Spaces features'));
  $spaces_types = spaces_types();
  $spaces_features = spaces_features();
  $output = '';
  $rows = array();
  foreach ($spaces_features as $id => $feature) {

    // Load the context object for this feature
    //   @TODO: change context_ui load operation so that it wouldn't
    //   wipe out the spaces extension if loaded.
    $context = context_ui_context('load', $feature);

    // Basic information about this feature
    $label = "<strong>" . $feature->spaces['label'] . "</strong>";
    $label .= "<div class='description'>" . $feature->spaces['description'] . "</div>";

    // Generate action links for this item
    // @TODO: currently, override contexts also have a "Delete" link --
    // it should probably say "Revert". However, there is no easy way
    // to tell that the context is an override of a code context. This
    // is probably something that needs to change upstream
    // (in context_ui).
    $links = array();
    if ($context->system == 0) {
      $links[] = l(t('Edit'), 'admin/build/context/edit/' . $context->cid);
      $links[] = l(t('Delete'), 'admin/build/context/delete/' . $context->cid, array(), 'destination=admin/build/spaces/features');
    }
    else {
      $links[] = l(t('Override'), 'admin/build/context/clone/' . $context->cid);
    }
    $links = implode(' | ', $links);

    // Generate human readable version of spaces types
    if (isset($feature->spaces['types']) && count($feature->spaces['types'])) {
      $types = array();
      foreach ($feature->spaces['types'] as $type) {
        $types[] = $spaces_types[$type]['title'];
      }
      $types = implode(', ', $types);
    }
    else {
      $types = t('All spaces');
    }
    $rows[] = array(
      $label,
      $types,
      $links,
    );
  }
  $header = array(
    t('Feature'),
    t('Usable for'),
    t('Actions'),
  );
  $output .= theme('table', $header, $rows);
  return $output;
}