You are here

function ds_layout_overview in Display Suite 6.3

Same name and namespace in other branches
  1. 6 includes/ds.display.inc \ds_layout_overview()
  2. 6.2 includes/ds.display.inc \ds_layout_overview()

General overview page.

1 string reference to 'ds_layout_overview'
_ds_ui_menu in includes/ds.registry.inc
Return menu items and import default settings.

File

includes/ds.display.inc, line 11
Display overview form.

Code

function ds_layout_overview() {
  $content = '';
  drupal_add_css(drupal_get_path('module', 'ds') . '/css/ds.css');
  $rows = array();
  foreach (module_implements('ds_api') as $module) {
    if (user_access('configure layout for ' . $module)) {
      $api_info = ds_api_info($module);

      // Build modes.
      $build_modes = ds_get_build_modes($module);
      foreach ($api_info['types']() as $tkey => $otype) {
        $type_name = $otype->type;
        $type = $type_name;
        $type_url_str = str_replace('_', '-', $type_name);

        // Global exclude.
        if (variable_get($module . '_type_' . $type, FALSE)) {
          continue;
        }
        $exclude_build_modes = variable_get($module . '_buildmodes_exclude', array());
        if (!empty($build_modes)) {
          $build_mode_rows = array();
          foreach ($build_modes as $bkey => $build_mode) {
            $excluded = isset($exclude_build_modes[$type_name][$bkey]) && $exclude_build_modes[$type_name][$bkey] == TRUE ? TRUE : FALSE;
            if ($excluded) {
              continue;
            }

            // Settings en status.
            $display_settings = variable_get($module . '_display_settings_' . $type, array());
            $settings_status = isset($display_settings[$bkey]['status']) ? $display_settings[$bkey]['status'] : DS_SETTINGS_UI;
            $row = array();
            $row[] = $build_mode['title'];
            $row[] = ds_settings_status($settings_status);
            $operations = l('Edit', DS_PATH_LAYOUT . '/' . $type_url_str . '/' . $bkey);
            if (user_access('revert overridden settings') && $settings_status == DS_SETTINGS_OVERRIDDEN) {
              $operations .= ' - ' . l('Revert', DS_PATH_TOOLS . '/revert/' . $module . '/' . $type_url_str . '/' . $bkey);
            }
            $row[] = $operations;
            $build_mode_rows[] = array(
              'data' => $row,
              'class' => 'ds-row-type',
            );
          }

          // Any build modes found ?
          if (!empty($build_mode_rows)) {
            $rows[] = array(
              array(
                'data' => check_plain(drupal_ucfirst($otype->name)),
                'colspan' => '3',
                'class' => 'ds-row-title',
              ),
            );
            $rows = array_merge($rows, $build_mode_rows);
          }
        }
      }
    }
  }

  // Special listing for views which are using the views fields style plugin.
  if (module_exists('views')) {
    $views_rows = array();
    $views_ui = module_exists('views_ui') && user_access('administer views');
    $views = views_get_all_views();
    foreach ($views as $v => $view) {
      foreach ($view->display as $d => $display) {
        if (isset($display->display_options['row_plugin']) && $display->display_options['row_plugin'] == 'ds_fields') {
          $views_row = array();
          $views_row[] = ucfirst($view->name);
          $views_row[] = '';
          if ($views_ui) {
            $views_row[] = l(t('Edit'), 'admin/build/views/edit/' . $view->name);
          }
          else {
            $views_row[] = '';
          }
          $views_rows[] = array(
            'data' => $views_row,
            'class' => 'ds-row-type',
          );
          break;
        }
      }
    }
    if (!empty($views_rows)) {
      $views_fields_explanation = 'This list of views are using the Display Suite fields plugin to render fields in regions.';
      if ($views_ui) {
        $views_fields_explanation .= ' The edit link will lead you to the edit screen of the view.';
      }
      else {
        $views_fields_explanation .= ' Views interface is disabled or you do not have access to edit the view.';
      }

      // Add empty row first and then the header of the views.
      $rows[] = array(
        array(
          'data' => ' ',
          'colspan' => '3',
          'class' => 'ds-row-type',
        ),
      );
      $rows[] = array(
        array(
          'data' => t('Views fields'),
          'colspan' => '3',
          'class' => 'ds-row-title',
        ),
      );
      $rows[] = array(
        array(
          'data' => t($views_fields_explanation),
          'colspan' => '3',
        ),
      );

      // Views rows
      $rows = array_merge($rows, $views_rows);
    }
  }
  if (!empty($rows)) {
    $content = theme('table', array(), $rows, array(
      'id' => 'ds-overview-page',
    ));
  }
  else {
    $content = '<p>' . t('No modules which provide Displays were found.') . '</p></p>' . t('For example, to change display options for nodes, use <a href="http://drupal.org/project/nd">Node Displays</a>. Other modules are listed in the <a href="http://drupal.org/node/644662">documentation</a>.') . '</p>';
  }
  return $content;
}