All pastes #269679 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-06 19:22 UTC
rendered paste body
/**
 * Implementation of hook_form_alter().
 */
function nice_versions_form_alter($form_id, &$form) {
  if ($form_id == 'system_modules') {
    foreach ($form['version'] as $module => $version) {
      $form['version'][$module]['#value'] = make_nice_version($version['#value']);
    }
  }
}

/**
 * Given a $Name$ or non-existent version string, parse
 * it into something more legible.
 */
function make_nice_version($version) {
  if (!$version) {
    $version = t('Not found');
  }
  elseif (preg_match('/\$Name: (.*?)\$/', $version, $matches)) {
    if (!trim($matches[1])) {
      $version = 'HEAD';
    }
    else {
      $version = $matches[1];
    }
  }

  return $version;
}