Changeset 491


Ignore:
Timestamp:
Sep 3, 2014 7:20:54 PM (10 years ago)
Author:
anonymous
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r489 r491  
    7171        'site_url' => '', // URL automatically determined by _SERVER['HTTP_HOST'] if not set here.
    7272        'images_path' => '', // Location for codebase-generated interface widgets (ex: "/admin/i").
     73        'site_version_file' => 'docs/version.txt', // File containing version number of this app, relative to the include path.
    7374
    7475        // The location the user will go if the system doesn't know where else to send them.
     
    380381        $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt';
    381382        $codebase_version = '';
    382         if (is_readable($codebase_version_file)) {
     383        if (is_readable($codebase_version_file) && !is_dir($codebase_version_file)) {
    383384            $codebase_version = trim(file_get_contents($codebase_version_file));
    384385            $this->setParam(array('codebase_version' => $codebase_version));
     
    390391        if (version_compare(PHP_VERSION, self::CODEBASE_MIN_PHP_VERSION, '<')) {
    391392            $this->logMsg(sprintf('PHP %s required for Codebase %s, using %s; some things will break.', self::CODEBASE_MIN_PHP_VERSION, $codebase_version, PHP_VERSION), LOG_NOTICE, __FILE__, __LINE__);
     393        }
     394
     395        // Set the application version if defined.
     396        if (is_readable($this->getParam('site_version_file')) && !is_dir($this->getParam('site_version_file'))) {
     397            $site_version = trim(file_get_contents($this->getParam('site_version_file'), true));
     398            $app->setParam(array('site_version' => $site_version));
     399            header('X-Site-Version: ' . $site_version);
    392400        }
    393401
Note: See TracChangeset for help on using the changeset viewer.