1 views_ui.admin.inc views_ui_list_page()

Page callback at admin/build/views to list all available views.

File

core/modules/views_ui/views_ui.admin.inc, line 243
Provides the Views' administrative interface.

Code

function views_ui_list_page() {
  views_ui_add_admin_css();

  $header = array(
    array('data' => t('Name'), 'class' => array('views-ui-name')),
    array('data' => t('Description'), 'class' => array('views-ui-description')),
    array('data' => t('Displays'), 'class' => array('views-ui-displays')),
    array('data' => t('Storage state'), 'class' => array('views-ui-storage')),
    array('data' => t('Operations'), 'class' => array('views-ui-operations')),
  );

  // Get and sort enabled views.
  $enabled = views_get_enabled_views();
  $enabled_sorted = array();
  foreach ($enabled as $key => $view) {
    $enabled_sorted[$key] = $view->human_name;
  }
  natcasesort($enabled_sorted);

  // Get and sort disabled views.
  $disabled = views_get_disabled_views();
  $disabled_sorted = array();
  foreach ($disabled as $key => $view) {
    $disabled_sorted[$key] = $view->human_name;
  }
  natcasesort($disabled_sorted);

  // Get complete set of views.
  $views = $enabled + $disabled;
  $sorted = array_keys($enabled_sorted + $disabled_sorted);

  $rows = array();
  foreach ($sorted as $key) {
    $view = $views[$key];

    $row = array();
    $row[] = array(
      'data' => theme('views_ui_view_name', array('view' => $view)),
      'class' => array('views-ui-name'),
      'data-label' => t('Name'),
    );
    $row[] = array(
      'data' => theme('views_ui_view_description', array('view' => $view)),
      'class' => array('views-ui-description'),
      'data-label' => t('Description'),
    );
    $row[] = array(
      'data' => theme('item_list', array('items' => _views_ui_get_displays($view))),
      'class' => array('views-ui-displays'),
      'data-label' => t('Displays'),
    );
    $row[] = array(
      'data' => theme('views_ui_view_storage', array('view' => $view)),
      'class' => array('views-ui-storage'),
      'data-label' => t('Storage state'),
    );
    $row[] = array(
      'data' => array(
        '#type' => 'operations',
        '#links' => _views_ui_get_operations($view),
      ),
      'class' => array('views-ui-operations'),
      'data-label' => t('Operations'),
    );

    $rows[] = array(
      'data' => $row,
      'class' => array(empty($view->disabled) ? 'enabled' : 'disabled'),
    );
  }

  $table = array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No views match the search criteria.'),
    'attributes' => array(
      'id' => 'views-list',
      'class' => array('views-list'),
    ),
  );
  return theme('table', $table);
}