' . t("Or you may want to attach this information to support requests and bug reports filed on drupal.org's project issue queues.", array('@status-report-export' => url('admin/reports/status/export'))) . '

'; break; } return $output; } // function sysexport_help /* ------------------------------ ADMIN ------------------------------ */ /** * Sets permission types */ function sysexport_perm() { return array('administer site configuration'); } // function sysexport_perm /** * Adds administrative config settings */ function sysexport_admin() { /**/ $form['sysexport_asbrowser'] = array( #description' => t("Force the browser to export report to the browser."), '#type' => 'fieldset', '#title' => t('Export to Browser'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['sysexport_asbrowser']['sysexport_asplain'] = array( '#description' => t("View in browser as plain text. This setting will be overridden during file export, if selected."), '#type' => 'checkbox', '#title' => t('View as Plain'), '#default_value' => variable_get('sysexport_asplain', 1), '#required' => TRUE, ); $form['sysexport_asfile'] = array( #description' => t("Force the browser to export report to a plain-text file."), '#type' => 'fieldset', '#title' => t('Export as file'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['sysexport_asfile']['sysexport_tofile'] = array( '#description' => t("Force the browser to export report to a plain-text file."), '#type' => 'checkbox', '#title' => t('Export as File'), '#default_value' => variable_get('sysexport_tofile', 1), '#required' => TRUE, ); $form['sysexport_asfile']['sysexport_exten'] = array( '#description' => t("String identifying the file extension of the exported settings file (if selected)."), '#type' => 'textfield', '#size' => 10, '#maxlength' => 9, '#title' => t('Exported File Extension'), '#default_value' => variable_get('sysexport_exten', 'info'), '#required' => TRUE, ); /** $form['asplain'] = array( '#description' => t("View in browser as plain text. This setting only relates to browser export -- if 'Export as File' is selected, this setting is ignored."), '#type' => 'checkbox', '#title' => t('View as Plain'), '#default_value' => variable_get('sysexport_asplain', 1), '#required' => TRUE, ); $form['asfile'] = array( '#description' => t("Force the browser to export report to a plain-text file."), '#type' => 'checkbox', '#title' => t('Export as File'), '#default_value' => variable_get('sysexport_asfile', 1), '#required' => TRUE, ); $form['exten'] = array( '#description' => t("String identifying the file extension of the exported settings file (if selected)."), '#type' => 'textfield', '#size' => 10, '#maxlength' => 9, '#title' => t('Exported File Extension'), '#default_value' => variable_get('sysexport_exten', 'info'), '#required' => TRUE, ); /**/ return system_settings_form($form); } /* ------------------------------ MENU ------------------------------ */ /** * Adds this item to the admin menu with hook_menu */ function sysexport_menu() { $items = array(); $items['admin/reports/status/export'] = array( 'title' => 'Export status report', 'page callback' => 'sysexport_page', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, ); $items['admin/settings/sysexport'] = array( 'title' => 'System Status Export', 'description' => 'Configure the behavior of the system status export.', 'page callback' => 'drupal_get_form', 'page arguments' => array('sysexport_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items; } // end sysexport_menu /* ------------------------------ CONTENT ------------------------------ */ /** * Menu callback: exports the site status report. * http://drupal.org/node/99529 */ function sysexport_page() { // Load .install files include_once './includes/install.inc'; // originally in patch as: DRUPAL_ROOT . '/includes/install.inc'; <-- is this D7 specific? drupal_load_updates(); // Check run-time requirements and status information. $requirements = module_invoke_all('requirements', 'runtime'); usort($requirements, '_system_sort_requirements'); // Fetch list of enabled modules and their versions. $modules = module_rebuild_cache(); $enabled = array(); foreach ($modules as $module) { if ($module->status && !isset($module->info['required'])) { $enabled[] = $module->name . (isset($module->info['version']) ? ' ' . $module->info['version'] : ''); } } sort($enabled); $requirements[] = array( 'title' => t('Enabled modules'), 'value' => theme('item_list', $enabled), ); // Generate output using a simple HTML markup structure. $output = '

Status Report

'; foreach ($requirements as $requirement) { if (empty($requirement['#type'])) { // Contrary to the on-site page, the export should not contain descriptions. $output .= '

' . $requirement['title'] . '

' . $requirement['value'] . '

'; } } // Force the browser to display the file save dialog. @jrs or just display it in the browser if (variable_get('sysexport_tofile', 1) == 1){ drupal_set_header('Content-Type: text/plain; charset=utf-8'); drupal_set_header('Content-Disposition: attachment; filename="system-status-report.' . variable_get('sysexport_exten', 'info') . '"'); // Strip links and any other HTML tags from the output. echo drupal_html_to_text($output, array('p', 'ul', 'li', 'h1', 'h2')); } else{ if (variable_get('sysexport_asplain', 1) == 1){ drupal_set_header('Content-Type: text/plain; charset=utf-8'); // Strip links and any other HTML tags from the output. echo drupal_html_to_text($output, array('p', 'ul', 'li', 'h1', 'h2')); } else echo $output; } exit; }