getVersion

Definition

getVersion($v)
test_it.php, line 212

Description

Returns Drupal major version. Basically this function strips down minor Drupal versions.

Return value

major drupal version

Code

<?php
function getVersion($v) {
  // TODO: change this so it latest head is configurable from settings page
  if ($v == '7.x-dev') {
    $version['min'] = 'HEAD';
    $version['maj'] = 'HEAD';
    $version['core'] = '7';
  }
  else {
    $version['min'] = version_to_tag($v);
    $version['maj'] = $version['min'];
    //string magic to get core version 5, 6 or 4.7
    $pieces = explode('-', $v);
    $pieces = explode('.', $pieces[0]);
    $ver = array();
    for($i = 0; $i < count($pieces) -1; $i++) {
      $ver[] = $pieces[$i];
    }
    // core version is 6, 5 or 4.7
    $version['core'] = implode('.', $ver);
  }
  return $version;
}
?>