You are here

function system_status_status_page in System Status 6.2

Same name and namespace in other branches
  1. 7 system_status_status.page.inc \system_status_status_page()

Return JSON formatted module information.

1 string reference to 'system_status_status_page'
system_status_menu in ./system_status.module
Implements hook_menu().

File

./system_status_status.page.inc, line 12

Code

function system_status_status_page() {
  $drupal_modules = module_list();
  $system_themes = list_themes(TRUE);
  $system_modules = array();
  foreach ($drupal_modules as $name) {
    $path = drupal_get_path('module', $name) . '/' . $name . '.info';
    $info = drupal_parse_info_file($path);
    $system_modules[$info['project']] = $info;
  }

  // Needless initialisation, but hey.
  $res = array(
    "core" => array(),
    "contrib" => array(),
    "custom" => "disabled",
  );
  foreach ($system_modules as $module) {
    if (isset($module['project'])) {
      if ($module['project'] == "drupal") {
        $res['core']['drupal'] = array(
          "version" => $module['version'],
        );
      }
      else {
        $res['contrib'][$module['project']] = array(
          "version" => $module['version'],
        );
      }
    }
  }
  foreach ($system_themes as $theme) {
    if (isset($theme->info['project']) && $theme->info['project'] == "drupal") {
      continue;
    }
    if (isset($theme->info['version']) && isset($theme->info['project'])) {
      $res['contrib'][$theme->info['project']] = array(
        "version" => $theme->info['version'],
      );
    }
  }
  if (variable_get('system_status_service_allow_drupalstatus', 1) == 1 && extension_loaded('mcrypt')) {
    $res = SystemStatusEncryption::encrypt(json_encode(array(
      "system_status" => $res,
    )));
    header('Content-Type: application/json');
    echo json_encode(array(
      "system_status" => "encrypted",
      "data" => $res,
      "drupal_version" => "6",
    ));
  }
  else {
    header('Content-Type: application/json');
    echo json_encode(array(
      "system_status" => $res,
      "drupal_version" => "6",
    ));
  }
}