You are here

function ds_layout_list in Display Suite 7.2

Same name and namespace in other branches
  1. 7 ds.layout.inc \ds_layout_list()

Menu callback: Show the layout list.

1 string reference to 'ds_layout_list'
_ds_menu in includes/ds.registry.inc
Implements hook_menu().

File

includes/ds.displays.inc, line 11
Shows the overview screen with all links to entities.

Code

function ds_layout_list() {
  $build = array();

  // All entities.
  $rows = array();
  $entities = entity_get_info();

  // Change label of node content type to 'Content' and move to the top
  if (isset($entities['node'])) {
    $node_entity = $entities['node'];
    $node_entity['label'] = 'Content';
    unset($entities['node']);
    $entities = array_merge(array(
      'node' => $node_entity,
    ), $entities);
  }
  if (isset($entities['comment'])) {
    $comment_entity = $entities['comment'];
    unset($entities['comment']);
    $entities['comment'] = $comment_entity;
  }
  foreach ($entities as $entity_type => $entity) {
    if (isset($entity['fieldable']) && $entity['fieldable'] || isset($entity['ds_display'])) {
      $rows = array();
      foreach ($entity['bundles'] as $bundle_type => $bundle) {
        $row = array();
        $path = isset($bundle['admin']['real path']) ? $bundle['admin']['real path'] : (isset($bundle['admin']['path']) ? $bundle['admin']['path'] : '');
        if (empty($path)) {
          continue;
        }
        $row[] = check_plain($bundle['label']);
        $links = array(
          l(t('Manage display'), $path . '/display'),
        );

        // Add Mangage Form link if this entity type is supported by ds_forms.
        if (module_exists('ds_forms') && _ds_forms_is_entity_type_supported($entity_type)) {
          $links[] = l(t('Manage form'), $path . '/fields');
        }
        $row[] = implode(' - ', $links);
        $rows[] = $row;
      }
      if (!empty($rows)) {
        $variables = array(
          'header' => array(
            array(
              'data' => $entity['label'],
            ),
            array(
              'data' => t('operations'),
              'class' => 'ds-display-list-options',
            ),
          ),
          'rows' => $rows,
        );
        $build['list_' . $entity_type] = array(
          '#markup' => theme('table', $variables),
        );
        $entity_rows = array();
        $rows = array();
      }
    }
  }
  drupal_add_css(drupal_get_path('module', 'ds') . '/css/ds.admin.css');
  return $build;
}