From 4a19b1665282bd8442de33e2fb98f470a3799bd6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 11 Jul 2014 12:04:11 +0100 Subject: [PATCH] CRM-14949 - For now we'll use imageUpload location to ensure consistency --- CRM/Utils/File.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index 3fdc463c2c..32819fcc1d 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -696,21 +696,28 @@ HTACCESS; */ static function addDynamicResource($fileName, $contents) { // First ensure the directory exists - $path = self::baseFilePath() . 'dynamic'; + $path = self::dynamicResourcePath(); if (!is_dir($path)) { self::createDir($path); self::restrictBrowsing($path); } - file_put_contents($path . DIRECTORY_SEPARATOR . $fileName, $contents); + file_put_contents("$path/$fileName", $contents); } /** * Get the path of a dynamic resource file + * With no fileName supplied, returns the path of the directory * @param string $fileName * @return string */ - static function dynamicResourcePath($fileName) { - return self::baseFilePath() . 'dynamic' . DIRECTORY_SEPARATOR . $fileName; + static function dynamicResourcePath($fileName = NULL) { + $config = CRM_Core_Config::singleton(); + // FIXME: Use self::baseFilePath once url issue has been resolved + $path = self::addTrailingSlash(str_replace('/persist/contribute', '', $config->imageUploadDir)) . 'dynamic'; + if ($fileName !== NULL) { + $path .= "/$fileName"; + } + return $path; } /** @@ -720,7 +727,8 @@ HTACCESS; */ static function dynamicResourceUrl($fileName) { $config = CRM_Core_Config::singleton(); - return str_replace('persist/contribute', 'dynamic', $config->imageUploadURL) . $fileName; + // FIXME: Need a better way of getting the url of the baseFilePath + return self::addTrailingSlash(str_replace('/persist/contribute', '', $config->imageUploadURL)) . 'dynamic/' . $fileName; } /** -- 2.25.1