1 system.admin.inc _system_modules_build_row($info, $extra)

Build a table row for the system modules page.

File

core/modules/system/system.admin.inc, line 741
Admin page callbacks for the system module.

Code

function _system_modules_build_row($info, $extra) {
  // Prepare the tag list by ensuring all tags are lower case.
  $tags = array();
  if (isset($info['tags'])) {
    foreach ($info['tags'] as $tag) {
      $tags[] = check_plain($tag);
    }
  }
  if (isset($info['package'])) {
    $tags[] = check_plain($info['package']);
  }
  if (empty($tags)) {
    $tags[] = 'Other';
  }

  // Add in the defaults.
  $extra += array(
    'requires' => array(),
    'required_by' => array(),
    'disabled' => FALSE,
    'enabled' => FALSE,
    'links' => array(),
    'core' => FALSE,
  );
  $form = array(
    '#tree' => TRUE,
  );
  // Set the basic properties.
  $form['name'] = array(
    '#markup' => $info['name'],
  );
  $form['description'] = array(
    '#markup' => t($info['description']),
  );
  $form['version'] = array(
    '#markup' => $info['version'],
  );
  $form['tags'] = array(
    '#markup' => implode(', ', $tags),
  );

  $form['#requires'] = $extra['requires'];
  $form['#required_by'] = $extra['required_by'];
  $form['#required_by_distribution'] = $extra['required_by_distribution'];

  // Check the compatibilities.
  $compatible = TRUE;
  $status_short = '';
  $status_long = '';

  // Check if this module was once a contributed module but is now in core.
  if (isset($info['merged_into_core'])) {
    $compatible = FALSE;
    $status_short .= t('No longer needed.') . ' ';
    $status_long .= t('This module is now built-into Backdrop CMS core and is no longer necessary.') . ' ';
  }
  // Check the core compatibility.
  elseif (!isset($info['backdrop']) || $info['backdrop'] != BACKDROP_CORE_COMPATIBILITY) {
    $compatible = FALSE;
    $status_short .= t('Incompatible with Backdrop CMS !core_version.', array('!core_version' => BACKDROP_CORE_COMPATIBILITY)) . ' ';
    $status_long .= t('This version is not compatible with Backdrop CMS !core_version.', array('!core_version' => BACKDROP_CORE_COMPATIBILITY)) . ' ';
  }

  // Ensure this module is compatible with the currently installed version of PHP.
  if (version_compare(phpversion(), $info['php']) < 0) {
    $compatible = FALSE;
    $status_short .= t('Incompatible with this version of PHP') . ' ';
    $php_required = $info['php'];
    if (substr_count($info['php'], '.') < 2) {
      $php_required .= '.*';
    }
    $status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) . ' ';
  }

  // If this module is compatible, present a checkbox indicating this module
  // may be installed. Otherwise, show a big red X.
  if ($compatible) {
    $form['enable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable'),
      '#default_value' => $extra['enabled'],
    );
    if ($extra['disabled']) {
      $form['enable']['#disabled'] = TRUE;
    }
  }
  else {
    $form['enable'] = array(
      '#markup' => '<span class="modules-error"><span class="element-invisible">' . t('Unable to enable') . '</span></span>',
    );
    $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => trim($status_long)));
  }

  // Build dropbutton links.
  $links = array();
  foreach (array('configure', 'permissions') as $key) {
    if (isset($extra['links'][$key])) {
      $links[$key] = $extra['links'][$key];
    }
  }
  if (!empty($links)) {
    $form['links'] = array(
      '#type' => 'dropbutton',
      '#links' => $links,
    );
  }

  return $form;
}