All pastes #246393 Raw Edit

Stuff

public text v1 · immutable
#246393 ·published 2006-11-12 04:22 UTC
rendered paste body
function system_extract_version($version_string) {
  $core_version = substr(VERSION, 0, strpos(VERSION, '.'));
  $pattern =  '/DRUPAL-'. $core_version .'(?:--(?P<major>\d+)(?:-(?P<minor>\d+))?)(?P<extra>-.+)?/';

  if (!$version_string) {
    $version = t('undefined');
  }
  elseif (empty($version_string)) {
    $version = t('latest dev');
  }
  elseif (preg_match($pattern, $version_string, $matches)) {
    if (!isset($matches['major'])) {
      $version = $core_version .'.x-dev';
    }
    elseif (!isset($matches['minor'])) {
      $version = $core_version .'.x-'. $matches['major'] .'.x-dev';
    }
    else {
      $version = $core_version .'.x-'. $matches['major'] .'-'. $matches['minor'] . drupal_strtolower($matches['extra']);
    }
  }

  return check_plain($version);
}