You are here

function styles_ui_containers_overview in Styles 7.2

Same name and namespace in other branches
  1. 6.2 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_containers_overview()
  2. 6 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_containers_overview()
  3. 7 contrib/styles_ui/styles_ui.admin.inc \styles_ui_containers_overview()

Page callback for various styles overview listing pages.

1 string reference to 'styles_ui_containers_overview'
styles_ui_menu in contrib/styles_ui/styles_ui.module
Implements hook_menu().

File

contrib/styles_ui/styles_ui.admin.inc, line 11
Administrative page callbacks for the Styles UI module.

Code

function styles_ui_containers_overview($field_type) {

  // Get the full list of styles.
  $styles = styles_default_styles();

  // Get the containers for this field type.
  $styles_containers = styles_default_containers();
  $field_containers = $styles_containers[$field_type];

  // Build our table listing of styles.
  $header = array(
    t('Styles'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  foreach ($styles[$field_type]['styles'] as $style_name => $style) {

    // What's the path to edit this style?
    $edit_path = $field_containers['admin']['path'] . '/edit/' . $style_name;
    $row = array(
      l(t('@style', array(
        '@style' => $style_name,
      )), $edit_path),
    );

    // Add our ops.
    if ($style['storage'] == STYLES_STORAGE_NORMAL) {
      $row[] = array(
        'data' => l(t('edit'), $edit_path),
      );
      $row[] = array(
        'data' => l(t('delete'), $field_containers['admin']['path'] . '/delete/' . $style_name),
      );
    }
    else {
      if ($style['storage'] == STYLES_STORAGE_OVERRIDE) {
        $row[] = array(
          'data' => l(t('edit'), $edit_path),
        );
        $row[] = array(
          'data' => l(t('revert'), $field_containers['admin']['path'] . '/delete/' . $style_name),
        );
      }
      else {
        $row[] = array(
          'data' => l(t('edit'), $edit_path),
          'colspan' => 2,
        );
      }
    }
    $rows[] = $row;
  }

  // Add a new style link to the empty table.
  // Note that the  link at the top of the page is placed in hook_menu.
  $field_info = field_info_field_types($field_type);
  $field_label = $field_info['label'];
  $title = 'Add ' . $field_label . ' style';
  $build['styles_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No styles available. <a href="@link">@add</a>.', array(
      '@add' => t($title),
      '@link' => url($field_containers['admin']['path'] . '/add'),
    )),
  );
  return $build;
}