Version: current

     1 <?php
     2 /**
     3  * Returns information about the current site instance.
     4  * @package sapphire
     5  * @subpackage control
     6  */
     7 class SapphireInfo extends Controller {
     8     static $allowed_actions = array(
     9         'baseurl',
    10         'version',
    11         'environmenttype',
    12     );
    13
    14     function init() {
    15         parent::init();
    16         if(!Director::is_cli() && !Permission::check('ADMIN')) return Security::permissionFailure();
    17     }
    18
    19     function Version() {
    20         $sapphireVersionFile = file_get_contents(BASE_PATH . '/sapphire/silverstripe_version');
    21
    22         if(strstr($sapphireVersionFile, "/sapphire/trunk")) {
    23             $sapphireVersion = "trunk";
    24         } else {
    25             preg_match("/sapphire\/(?:(?:branches)|(?:tags))(?:\/rc)?\/([A-Za-z0-9._-]+)\/silverstripe_version/", $sapphireVersionFile, $matches);
    26             $sapphireVersion = $matches[1];
    27         }
    28
    29         return $sapphireVersion;
    30     }
    31
    32     function EnvironmentType() {
    33         if(Director::isLive()) return "live";
    34         else if(Director::isTest()) return "test";
    35         else return "dev";
    36     }
    37
    38     function BaseURL() {
    39         return Director::absoluteBaseURL();
    40     }
    41 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -