Skip to content

Commit

Permalink
API CHANGE silverstripe_version file now contains the plain version n…
Browse files Browse the repository at this point in the history
…umber, rather than an SVN path
  • Loading branch information
chillu committed Feb 1, 2012
1 parent a67c6ce commit d261f44
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
24 changes: 7 additions & 17 deletions admin/code/LeftAndMain.php
Expand Up @@ -1131,27 +1131,17 @@ public function PreviewLink() {
/**
* Return the version number of this application.
* Uses the subversion path information in <mymodule>/silverstripe_version
* (automacially replaced $URL$ placeholder).
* (automacially replaced by build scripts).
*
* @return string
*/
public function CMSVersion() {
$sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
$sapphireVersion = $this->versionFromVersionFile($sapphireVersionFile);

return "sapphire: $sapphireVersion";
}

/**
* Return the version from the content of a silverstripe_version file
*/
public function versionFromVersionFile($fileContent) {
if(preg_match('/\/trunk\/silverstripe_version/', $fileContent)) {
return "trunk";
} else {
preg_match("/\/(?:branches|tags\/rc|tags\/beta|tags\/alpha|tags)\/([A-Za-z0-9._-]+)\/silverstripe_version/", $fileContent, $matches);
return ($matches) ? $matches[1] : null;
}
$sapphireVersion = file_get_contents(BASE_PATH . '/cms/silverstripe_version');
if(!$sapphireVersion) $sapphireVersion = _t('LeftAndMain.VersionUnknown', 'unknown');
return sprintf(
"sapphire: %s",
$sapphireVersion
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/Includes/LeftAndMain_Menu.ss
@@ -1,7 +1,7 @@
<div class="cms-menu cms-panel cms-panel-layout west" id="cms-menu" data-layout="{type: 'border'}">
<div class="cms-panel-header cms-logo-header north">
<div class="cms-logo">
<a href="http://www.silverstripe.org/" target="_blank">
<a href="http://www.silverstripe.org/" target="_blank" title="SilverStripe (Version - $CMSVersion)">
SilverStripe <% if CMSVersion %><abbr class="version">$CMSVersion</abbr><% end_if %>
</a>
<span>$SiteConfig.Title</span>
Expand Down
19 changes: 0 additions & 19 deletions admin/tests/LeftAndMainTest.php
Expand Up @@ -82,25 +82,6 @@ public function testSaveTreeNodeParentID() {
$this->assertEquals(3, $page32->Sort, 'Children pages after insertion are resorted');
}

/**
* Test that CMS versions can be interpreted appropriately
*/
public function testCMSVersion() {
$l = new LeftAndMain();
$this->assertEquals("2.4", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/branches/2.4/silverstripe_version $'));
$this->assertEquals("2.2.0", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/tags/2.2.0/silverstripe_version $'));
$this->assertEquals("trunk", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/trunk/silverstripe_version $'));
$this->assertEquals("2.4.0-alpha1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/tags/alpha/2.4.0-alpha1/silverstripe_version $'));
$this->assertEquals("2.4.0-beta1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/tags/beta/2.4.0-beta1/silverstripe_version $'));
$this->assertEquals("2.4.0-rc1", $l->versionFromVersionFile(
'$URL: http://svn.silverstripe.com/open/modules/sapphire/tags/rc/2.4.0-rc1/silverstripe_version $'));
}

/**
* Check that all subclasses of leftandmain can be accessed
*/
Expand Down
1 change: 0 additions & 1 deletion silverstripe_version
@@ -1 +0,0 @@
$URL$

0 comments on commit d261f44

Please sign in to comment.