1 system.admin.inc system_get_debug_info()

Compiles the various information for the debug info page.

@since 1.28.0 function added.

See also

system_debug_info()

File

core/modules/system/system.admin.inc, line 2383
Admin page callbacks for the System module.

Code

function system_get_debug_info() {
  global $language;

  // An array that is later passed to sprintf() so that the final output can be
  // formatted in two columns of plain text. Each entry is an array with two
  // keys, "label" and "value". The number of spaces between the two columns is
  // dynamically calculated, based on the length of the string of the first
  // column. This ensures that the strings in the second column all start at the
  // same point and appear as vertically aligned.
  $debug_info_lines = array();

  $empty_line = array();

  $jquery_library = backdrop_get_library('system', 'jquery');
  $jquery_ui_library = backdrop_get_library('system', 'ui');
  $core_version = BACKDROP_VERSION;

  // Main system info.
  $system_info = array(
    // Intentionally not translated to match the trademark.
    'Backdrop CMS:' => $core_version,
    t('Installation profile:') => backdrop_get_profile(),
    t('PHP version:') => phpversion(),
    t('Drupal 7 compatibility:') => settings_get('backdrop_drupal_compatibility') ? t('on') : t('off'),
    t('Database server:') => Database::getConnection()->version(),
    t('Web server:') => check_plain($_SERVER['SERVER_SOFTWARE']),
    t('jQuery version:') => $jquery_library['version'],
    t('jQuery UI version:') => $jquery_ui_library['version'],
  );
  foreach ($system_info as $label => $value) {
    $debug_info_lines[] = array(
      'label' => $label,
      'value' => $value,
    );
  }

  // Get the current list of all modules available on the site.
  $modules = system_rebuild_module_data();

  // Text editors info.
  $text_editor_usage = array();
  $text_editors = filter_get_editors();
  $text_formats = filter_formats(NULL, TRUE);
  foreach ($text_formats as $format_info) {
    if (!empty($format_info->editor)) {
      $editor = $text_editors[$format_info->editor];
      $editor_label = $editor['label'];
      // Add a suffix with the editor version or the editor library version
      // to the editor label.
      if (!empty($editor['library_version'])) {
        $editor_label .= ' ' . t('version') . ': ' . $editor['library_version'];
      }
      elseif (isset($modules[$editor['module']]->info['version'])) {
        $editor_label .= ' ' . t('version') . ': ' . $modules[$editor['module']]->info['version'];
      }
      $text_editor_usage[$editor_label][] = $format_info->name;
    }
  }
  foreach ($text_editor_usage as $editor => $formats) {
    $debug_info_lines[] = array(
      'label' => $editor,
      'value' => t('Used in formats: @formats', array('@formats' => implode(', ', $formats))),
    );
  }

  $debug_info_lines[] = $empty_line;

  // Theme info, grouped by default theme and admin theme.
  $debug_info_lines[] = array(
    'label' => t('Themes'),
  );
  $debug_info_lines[] = array(
    'label' => '======',
  );

  $config = config('system.core');
  $themes = array(
    'default_theme' => $config->get('theme_default'),
    'admin_theme' => $config->get('admin_theme'),
  );

  // Collect the current list of themes, looping up through base themes.
  $all_theme_data = system_rebuild_theme_data();
  $content_theme = $config->get('node_admin_theme') ? $themes['admin_theme'] : $themes['default_theme'];
  foreach ($themes as $theme_role => $theme) {
    $theme_data = (array) $all_theme_data[$theme];
    $indent_level = '';
    while ($theme_data) {
      $theme_version = isset($theme_data['info']['version']) ? $theme_data['info']['version'] : '';
      $content_theme_indicator = $content_theme == $theme_data['name'] ? '*' : '';

      if ($indent_level === '') {
        $theme_debug_label = $theme_role == 'default_theme' ? t('Default theme:') : t('Admin theme:');
        $theme_debug_value = $theme_data['info']['name'] . $content_theme_indicator . ' (' . $theme_data['name'] . ') ' . $theme_version;
      }
      else {
        $base_prefix = $language->direction == LANGUAGE_RTL ? '' : $indent_level . ' ↳ ';
        $base_suffix = $language->direction == LANGUAGE_RTL ? ' ↲ ' . $indent_level : '';
        $theme_debug_label = $base_prefix . t('base theme:') . $base_suffix;
        $theme_debug_value = $base_prefix . $theme_data['info']['name'] . ' (' . $theme_data['name'] . ') ' . $theme_version . $base_suffix;
      }

      $debug_info_lines[] = array(
        'label' => $theme_debug_label,
        'value' => $theme_debug_value,
      );

      // Loop up to the next base theme if present.
      $base_theme_name = isset($theme_data['info']['base theme']) ? $theme_data['info']['base theme'] : '';
      $theme_data = isset($all_theme_data[$base_theme_name]) ? (array) $all_theme_data[$base_theme_name] : '';
      $indent_level = '  ' . $indent_level;
    }
  }
  $debug_info_lines[] = array(
    'value' => t('*used when editing or creating content'),
  );

  // Module info, grouped by core, contrib, custom, and other.
  $debug_info_lines[] = $empty_line;
  $debug_info_lines[] = array(
    'label' => t('Enabled modules'),
  );
  $debug_info_lines[] = array(
    'label' => '===============',
  );
  $debug_info_lines[] = $empty_line;

  $module_info_lines = array(
    'core' => array(),
    'contrib' => array(),
    'custom' => array(),
    'other' => array(),
  );
  foreach ($modules as $module_name => $module_data) {
    // Only include non-hidden and enabled modules in the output.
    if (empty($module_data->info['hidden']) && $module_data->status) {
      // Core modules:
      if (strstr($module_data->uri, 'core/modules/')) {
        $module_info_lines['core'][] = array(
          'label' => $module_name,
          'value' => $core_version,
        );
      }
      else {
        // Contrib modules:
        $module_version = isset($module_data->info['version']) ? $module_data->info['version'] : '-';
        if (strstr($module_data->uri, '/contrib/') || !empty($module_data->info['project'])) {
          $module_info_lines['contrib'][] = array(
            'label' => $module_name,
            'value' => $module_version,
          );
        }
        // Custom modules:
        elseif (strstr($module_data->uri, '/custom/')) {
          $module_info_lines['custom'][] = array(
            'label' => $module_name,
            'value' => $module_version,
          );
        }
        // Anything we can't identify as clearly contrib or custom:
        else {
          $module_info_lines['other'][] = array(
            'label' => $module_name,
            'value' => $module_version,
          );
        }
      }
    }
  }

  $module_group_titles = array(
    'core' => t('Core'),
    'contrib' => t('Contrib'),
    'custom' => t('Custom'),
    'other' => t('Other'),
  );
  foreach ($module_info_lines as $module_group => $module_group_lines) {
    if (empty($module_group_lines)) {
      continue;
    }
    $group_title = $module_group_titles[$module_group];
    $debug_info_lines[] = array(
      'label' => $group_title,
    );
    // Add an underline for the module group.
    $debug_info_lines[] = array(
      'label' => str_repeat('-', backdrop_strlen($group_title)),
    );
    $debug_info_lines = array_merge($debug_info_lines, $module_group_lines);
    $debug_info_lines[] = $empty_line;
  }

  return $debug_info_lines;
}