From bee8e4a75b269860d1a3157b49ac97804f2d527e Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 14 Oct 2015 12:51:20 -0400 Subject: [PATCH] Allow APPLICATION_PATH to be defined as an Apache environment variable - Avoids use of __DIR__ (which doesn't work properly with symlinked files). - Also use APPLICATION_PATH in theme base directory. - Fixed line lengths in index.php. --- config/vufind/httpd-vufind.conf | 5 +++++ module/VuFindTheme/Module.php | 2 +- public/index.php | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/config/vufind/httpd-vufind.conf b/config/vufind/httpd-vufind.conf index a42e5a29f78..3cfdfea49be 100644 --- a/config/vufind/httpd-vufind.conf +++ b/config/vufind/httpd-vufind.conf @@ -61,4 +61,9 @@ Alias /vufind /usr/local/vufind/public # Multiple modules may be specified separated by commas. This mechanism can be used to override # core VuFind functionality without modifying core code. #SetEnv VUFIND_LOCAL_MODULES VuFindLocalTemplate + + # This line overrides the detection of VuFind base directory. By default it is determined from + # the location of the index.php file, but in case it is e.g. symlinked or there is another reason + # to define the path manually, you can uncomment and modify this line. + #SetEnv VUFIND_APPLICATION_PATH /usr/local/vufind </Directory> diff --git a/module/VuFindTheme/Module.php b/module/VuFindTheme/Module.php index 26b0d39276d..a154caabd17 100644 --- a/module/VuFindTheme/Module.php +++ b/module/VuFindTheme/Module.php @@ -100,6 +100,6 @@ class Module */ public static function getThemeInfo() { - return new ThemeInfo(realpath(__DIR__ . '/../../themes'), 'bootprint3'); + return new ThemeInfo(realpath(APPLICATION_PATH . '/themes'), 'bootprint3'); } } diff --git a/public/index.php b/public/index.php index ee18e67132b..39e0afbcece 100644 --- a/public/index.php +++ b/public/index.php @@ -13,15 +13,25 @@ if (!empty($xhprof) && extension_loaded('xhprof')) { // Define path to application directory defined('APPLICATION_PATH') - || define('APPLICATION_PATH', dirname(__DIR__)); + || define( + 'APPLICATION_PATH', + (getenv('VUFIND_APPLICATION_PATH') ? getenv('VUFIND_APPLICATION_PATH') + : dirname(__DIR__)) + ); // Define application environment defined('APPLICATION_ENV') - || define('APPLICATION_ENV', (getenv('VUFIND_ENV') ? getenv('VUFIND_ENV') : 'production')); + || define( + 'APPLICATION_ENV', + (getenv('VUFIND_ENV') ? getenv('VUFIND_ENV') : 'production') + ); // Define path to local override directory defined('LOCAL_OVERRIDE_DIR') - || define('LOCAL_OVERRIDE_DIR', (getenv('VUFIND_LOCAL_DIR') ? getenv('VUFIND_LOCAL_DIR') : '')); + || define( + 'LOCAL_OVERRIDE_DIR', + (getenv('VUFIND_LOCAL_DIR') ? getenv('VUFIND_LOCAL_DIR') : '') + ); // Save original working directory in case we need to remember our context, then // switch to the application directory for convenience: -- GitLab