Index: libraries.module =================================================================== RCS file: /cvs/drupal/contributions/modules/libraries/libraries.module,v retrieving revision 1.4 diff -u -p -r1.4 libraries.module --- libraries.module 3 Apr 2010 18:55:10 -0000 1.4 +++ libraries.module 31 May 2010 23:02:08 -0000 @@ -7,6 +7,102 @@ */ /** + * Implements hook_menu(). + */ +function libraries_menu() { + $items['admin/reports/libraries'] = array( + 'title' => 'Libraries', + 'description' => 'An overview of all required and installed external libraries', + 'page callback' => 'libraries_overview', + 'access arguments' => array('view site reports'), + 'parent' => 'admin/reports', + ); + return $items; +} + +/** + * Shows an administrative overview of all libraries. + */ +function libraries_overview() { + // Gather information about all libraries. + $libraries = libraries_detect(libraries_info()); + // Build the overview table. + $header = array( + array( + 'data' => t('Name'), + 'class' => array('libraries-name'), + ), + t('Homepage'), + t('Version'), + t('Location'), + ); + $rows = array(); + foreach ($libraries as $name => $library) { + if ($library['installed'] == TRUE) { + $status = 'ok'; + $collapsed = TRUE; + $text = t('This library was installed successfully.'); + $version = $library['version']; + } + elseif ($library['error'] != t('%library could not be found.', array('%library' => $library['title']))) { + $status = 'warning'; + if ($library['error'] == t('The version of %library could not be detected.', array('%library' => $library['title']))) { + $collapsed = FALSE; + $text = t('Please contact the maintainer(s) of one of the modules that implement this library. The provided information about this library seems to be inaccurate.'); + $version = t('Could not be detected'); + } + elseif ($library['error'] == t('The installed version %version of %library is not supported.', array('%version' => $library['version'], '%library' => $library['title']))) { + $collapsed = FALSE; + $text = t('Please replace the library with the latest version.', array('@download-url' => $library['download url'])); + $version = t('@version (Unsupported)', array('@version' => $library['version'])); + } + } + else { + $status = 'error'; + $collapsed = FALSE; + $text = t('Please download the latest version of this library and place it in one of the following directories:', array('@download-url' => $library['download url'], '@library' => $name, '@conf-path' => conf_path())); + $version = ''; + $library['library path'] = ''; + } + $fieldset = array( + '#parents' => array(), + '#collapsible' => TRUE, + '#collapsed' => $collapsed, + '#id' => 'libraries-' . $name, + '#attributes' => array(), + '#children' => '', + '#title' => $library['title'], + '#value' => $text, + ); + $fieldset = form_process_fieldset($fieldset, $form_state); + drupal_process_attached($fieldset); + $fieldset = theme_fieldset(array('element' => $fieldset)); + $rows[] = array( + 'data' => array( + $fieldset, + l($library['vendor url'], $library['vendor url']), + $version, + $library['library path'], + ), + 'class' => array($status), + ); + } + + drupal_add_css('.libraries-name{width:50%;}', 'inline'); + return theme_table(array( + 'header' => $header, + 'rows' => $rows, + 'attributes' => array( + 'class' => array('system-status-report'), + ), + 'caption' => '', + 'colgroups' => array(), + 'sticky' => TRUE, + 'empty' => t('Currently no module implements an external library.'), + )); +} + +/** * Helper function to build paths to libraries. * * @param $library