Theme function for the system themes form.

Parameters

$form: An associative array containing the structure of the form.

Related topics

File

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

Code

function theme_system_themes_form($form) {
  foreach (element_children($form) as $key) {

    // Only look for themes
    if (!isset($form[$key]['info'])) {
      continue;
    }

    // Fetch info
    $info = $form[$key]['info']['#value'];

    // Localize theme description.
    $description = t($info['description']);

    // Make sure it is compatible and render the checkbox if so.
    if (isset($form['status']['#incompatible_themes_core'][$key])) {
      unset($form['status'][$key]);
      $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
      $description .= '<div class="incompatible">' . t('This version is incompatible with the !core_version version of Drupal core.', array(
        '!core_version' => VERSION,
      )) . '</div>';
    }
    elseif (isset($form['status']['#incompatible_themes_php'][$key])) {
      unset($form['status'][$key]);
      $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
      $php_required = $form['status']['#incompatible_themes_php'][$key];
      if (substr_count($php_required, '.') < 2) {
        $php_required .= '.*';
      }
      $description .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array(
        '@php_required' => $php_required,
        '!php_version' => phpversion(),
      )) . '</div>';
    }
    else {
      $status = drupal_render($form['status'][$key]);
    }

    // Style theme info
    $theme = '<div class="theme-info"><h2>' . $info['name'] . '</h2><div class="description">' . $description . '</div></div>';

    // Build rows
    $row = array();
    $row[] = drupal_render($form[$key]['screenshot']);
    $row[] = $theme;
    $row[] = isset($info['version']) ? $info['version'] : '';
    $row[] = array(
      'data' => $status,
      'align' => 'center',
    );
    if ($form['theme_default']) {
      $row[] = array(
        'data' => drupal_render($form['theme_default'][$key]),
        'align' => 'center',
      );
      $row[] = array(
        'data' => drupal_render($form[$key]['operations']),
        'align' => 'center',
      );
    }
    $rows[] = $row;
  }
  $header = array(
    t('Screenshot'),
    t('Name'),
    t('Version'),
    t('Enabled'),
    t('Default'),
    t('Operations'),
  );
  $output = theme('table', $header, $rows);
  $output .= drupal_render($form);
  return $output;
}