You are here

function pm_recommended_modules_table in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 includes/pm.recommended.inc \pm_recommended_modules_table()

Generates a table of recommended modules.

1 call to pm_recommended_modules_table()
pm_admin_settings in includes/pm.settings.inc
Defines the administration settings form.

File

includes/pm.recommended.inc, line 10
Recommended modules helper functions.

Code

function pm_recommended_modules_table() {

  // Initialise arrays.
  $header = array(
    'name' => t('Module'),
    'functionality' => t('Functionality'),
    'operations' => t('Operations'),
  );
  $rows = array();

  // Retrieve row information.
  $recommended_modules = module_invoke_all('pm_recommended_modules_info');
  $available_modules = pm_get_available_modules();
  foreach ($recommended_modules as $shortname => $recommended_module) {
    if (isset($available_modules[$shortname])) {
      if ((bool) $available_modules[$shortname]['status']) {
        $status = '<span class="admin-enabled">enabled</span>';
        $operations = '';
      }
      else {
        $status = '<span class="admin-disabled">disabled</span>';
        if (drupal_valid_path('admin/modules')) {
          $operations = l(t('Enable'), 'admin/modules');
        }
        else {
          $operations = 'Contact an administrator to enable this module';
        }
      }
    }
    else {
      $status = '<span class="admin-missing">missing</span>';
      $operations = l(t('Download'), $recommended_module['download']);
    }
    $rows[] = array(
      'name' => '<strong>' . $recommended_module['name'] . '</strong> (' . $status . ')',
      'functionality' => $recommended_module['functionality'],
      'operations' => $operations,
    );
  }

  // Generate table.
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No additional modules are currently recommended.'),
  ));
}