2008-01-16 06:24:27 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Returns information about the current site instance.
|
2008-06-15 15:33:53 +02:00
|
|
|
* @package sapphire
|
|
|
|
* @subpackage control
|
2008-01-16 06:24:27 +01:00
|
|
|
*/
|
|
|
|
class SapphireInfo extends Controller {
|
2008-10-02 22:43:22 +02:00
|
|
|
static $allowed_actions = array(
|
|
|
|
'baseurl',
|
|
|
|
'version',
|
|
|
|
'environmenttype',
|
|
|
|
);
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
parent::init();
|
|
|
|
if(!Director::is_cli() && !Permission::check('ADMIN')) return Security::permissionFailure();
|
|
|
|
}
|
|
|
|
|
2008-03-03 00:21:58 +01:00
|
|
|
function Version() {
|
2010-04-13 01:14:36 +02:00
|
|
|
$sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
|
2008-03-03 00:21:58 +01:00
|
|
|
|
|
|
|
if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
|
|
|
|
$sapphireVersion = "trunk";
|
|
|
|
} else {
|
|
|
|
preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches);
|
|
|
|
$sapphireVersion = $matches[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sapphireVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
function EnvironmentType() {
|
|
|
|
if(Director::isLive()) return "live";
|
|
|
|
else if(Director::isTest()) return "test";
|
|
|
|
else return "dev";
|
2008-01-16 06:24:27 +01:00
|
|
|
}
|
|
|
|
|
2008-03-03 00:21:58 +01:00
|
|
|
function BaseURL() {
|
|
|
|
return Director::absoluteBaseURL();
|
|
|
|
}
|
2008-01-16 06:24:27 +01:00
|
|
|
}
|