Changeset 526


Ignore:
Timestamp:
Jun 17, 2015 11:47:23 PM (9 years ago)
Author:
anonymous
Message:

Enabled App to load version from json file. Lock URL fixed to permit additional query arguments. Return array instead of object for Prefs cookie json.

Location:
trunk/lib
Files:
3 edited

Legend:

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

    r524 r526  
    7575        'site_url' => '', // URL automatically determined by _SERVER['HTTP_HOST'] if not set here.
    7676        'images_path' => '', // Location for codebase-generated interface widgets (ex: "/admin/i").
     77        'site_version' => '', // Version of this application (set automatically during start() if site_version_file is used).
    7778        'site_version_file' => 'docs/version.txt', // File containing version number of this app, relative to the include path.
    7879
     
    470471        // Set the application version if defined.
    471472        if (false !== $site_version_file = stream_resolve_include_path($this->getParam('site_version_file'))) {
    472             $site_version = trim(file_get_contents($site_version_file));
     473            if (mb_strpos($site_version_file, '.json') !== false) {
     474                $version_json = json_decode(trim(file_get_contents($site_version_file)), true);
     475                $site_version = $version_json['version'];
     476            } else {
     477                $site_version = trim(file_get_contents($site_version_file));
     478            }
    473479            $this->setParam(array('site_version' => $site_version));
    474             if (!defined('_CLI')) {
    475                 if (!headers_sent($h_file, $h_line)) {
    476                     header('X-Site-Version: ' . $site_version);
    477                 } else {
    478                     $this->logMsg(sprintf('Unable to set X-Site-Version; headers already sent (output started in %s : %s)', $h_file, $h_line), LOG_DEBUG, __FILE__, __LINE__);
    479                 }
     480        }
     481        if (!defined('_CLI') && $this->getParam('site_version')) {
     482            if (!headers_sent($h_file, $h_line)) {
     483                header('X-Site-Version: ' . $site_version);
     484            } else {
     485                $this->logMsg(sprintf('Unable to set X-Site-Version; headers already sent (output started in %s : %s)', $h_file, $h_line), LOG_DEBUG, __FILE__, __LINE__);
    480486            }
    481487        }
  • trunk/lib/Lock.inc.php

    r523 r526  
    377377        $app =& App::getInstance();
    378378
    379         $app->dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe())));
     379        $app->dieURL($this->getParam('error_url'), array('lock_id' => $this->data['lock_id'], 'boomerang' => urlencode(absoluteMe())));
    380380    }
    381381
  • trunk/lib/Prefs.inc.php

    r502 r526  
    333333            $name = $this->_getCookieName($key);
    334334            if ($this->exists($key)) {
    335                 $val = json_decode($_COOKIE[$name]);
     335                $val = json_decode($_COOKIE[$name], true);
    336336                $app->logMsg(sprintf('Found %s in cookie: %s', $key, getDump($val)), LOG_DEBUG, __FILE__, __LINE__);
    337337                return $val;
Note: See TracChangeset for help on using the changeset viewer.