diff --git a/libraries.admin.inc b/libraries.admin.inc index 4d885f8..1b6aecc 100644 --- a/libraries.admin.inc +++ b/libraries.admin.inc @@ -20,9 +20,10 @@ * The form array for the overview form. */ function libraries_admin_overview(array $form, array &$form_state) { - $header = array(t('Name'), t('Status'), t('Installed version'), t('Links')); + $header = array(t('Name'), t('Status'), t('Installed version'), t('Provider'), t('Links')); $libraries = array(); $rows[] = array(); + $modules_data = system_rebuild_module_data(); foreach (libraries_info() as $name => $info) { $libraries[$name] = libraries_detect($name); @@ -39,11 +40,16 @@ function libraries_admin_overview(array $form, array &$form_state) { $actions[] = l('Download', $library['download url']); } + $provider_info = libraries_get_provider_info($library); + $provider = drupal_ucfirst($provider_info['type']); + $name = $provider_info['name']; + $rows[] = array( 'data' => array( l($library['name'], 'admin/reports/libraries/' . $machine_name), ($library['installed'] ? t('OK') : drupal_ucfirst($library['error'])), (isset($library['version']) ? $library['version'] : ''), + $provider . '
' . $name, implode(' | ', $actions), ), 'class' => ($library['installed'] ? array('ok') : array('error')), @@ -78,21 +84,33 @@ function libraries_admin_overview(array $form, array &$form_state) { * * @todo Add some var_export($library)-style output */ -function libraries_admin_library_status_form(array $form, array &$form_state, $name) { - $library = libraries_detect($name); +function libraries_admin_library_status_form(array $form, array &$form_state, $library) { + drupal_set_title(t('Status report for library %library', array('%library' => $library['name'])), PASS_THROUGH); - if ($library === FALSE) { - // @todo MENU_NOT_FOUND does not work here. - return; - } + if (isset($library['info type'])) { + $provider_info = libraries_get_provider_info($library); + $provider = drupal_ucfirst($provider_info['type']); - drupal_set_title(t('Status report for library %library', array('%library' => $library['name'])), PASS_THROUGH); + switch ($library['info type']) { + case 'module': + $name = sprintf('%s (%s)', $provider_info['name'], $library['module']); + break; + case 'theme': + $name = sprintf('%s (%s)', $provider_info['name'], $library['theme']); + break; + + case 'info file': + $name = sprintf('%s (%s)', $provider_info['name'], $library['info file']); + break; + } + } if ($library['installed']) { $rows = array(); drupal_set_message(t('The %name library is installed correctly.', array('%name' => $library['name']))); $header = array(array('data' => '' . t('General information') . '', 'colspan' => 2, 'class' => 'table-heading', 'no_striping' => TRUE)); + $rows[] = array('' . t('Provider') . '', sprintf('%s %s', $provider, $name)); $rows[] = array('' . t('Name') . '', check_plain($library['name'])); $rows[] = array('' . t('Machine name') . '', check_plain($library['machine name'])); @@ -196,8 +214,7 @@ function libraries_admin_library_status_form(array $form, array &$form_state, $n // @todo Add support for themes by accessing $library['info type'] if (!empty($library['module'])) { $form['status']['not_detected']['help']['#markup'] = t('If yes, the library information is corrupted. Contact the maintainer of the %module module with the following information:', array( - // @todo Use the human-readable module name instead. - '%module' => $library['module'], + '%module' => $provider_info['name'], )) . '
'; } // Otherwise contact the author of the info file. @@ -256,8 +273,7 @@ function libraries_admin_library_status_form(array $form, array &$form_state, $n // @todo Add support for themes by accessing $library['info type'] if (!empty($library['module'])) { $form['status']['not_supported']['help']['#markup'] = t('If you are bound to the current version of the library, ask the maintainer of the %module module to provide support for version %version.', array( - // @todo Use the human-readable module name instead. - '%module' => $library['module'], + '%module' => $provider_info['name'], '%version' => $library['version'], )) . '
'; } @@ -270,8 +286,13 @@ function libraries_admin_library_status_form(array $form, array &$form_state, $n } break; - // @todo Add a 'missing dependency' case. - // @todo Add a 'incompatible dependency' case. + case 'missing dependency': + $form['status']['missing_dependency']['instruction']['#markup'] = t('There a missing dependency in your configuration that prevent this library to work properly.') . '
'; + break; + + case 'incompatible dependency': + $form['status']['incompatible_dependency']['instruction']['#markup'] = t('There an incompatible dependency in your configuration that prevent this library to work properly.') . '
'; + break; } } @@ -306,3 +327,34 @@ function libraries_get_example_filepath(array $library) { } return array($filepath, $file); } + +/** + * Return information of the library's provider. + * + * @param array $library + * The library you want to get information from. + * @return array + * The provider information + */ +function libraries_get_provider_info($library) { + $provider_info = array(); + + switch ($library['info type']) { + case 'module': + $provider_info = system_get_info('module', $library['module']); + $provider_info['type'] = 'module'; + break; + + case 'theme': + $provider_info = system_get_info('theme', $library['theme']); + $provider_info['type'] = 'theme'; + break; + + case 'info file': + $provider_info = array('name' => $library['info file']); + $provider_info['type'] = 'info file'; + break; + } + + return $provider_info; +} diff --git a/libraries.module b/libraries.module index 0b45cd9..ebbddd6 100644 --- a/libraries.module +++ b/libraries.module @@ -895,7 +895,7 @@ function libraries_menu() { 'access arguments' => array('access site reports'), 'file' => 'libraries.admin.inc' ); - $items['admin/reports/libraries/%'] = array( + $items['admin/reports/libraries/%libraries'] = array( 'title' => 'Library status report', 'description' => 'Status overview for a single library', 'page callback' => 'drupal_get_form',