mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-26 20:45:47 +02:00
Merge pull request #803 from halkyon/temp_path_tinymce
Have tiny_mce_gzip.php use local silverstripe-cache folder if available
This commit is contained in:
commit
445aabfe2e
@ -176,11 +176,31 @@ define('THIRDPARTY_PATH', BASE_PATH . '/' . THIRDPARTY_DIR);
|
|||||||
define('ASSETS_DIR', 'assets');
|
define('ASSETS_DIR', 'assets');
|
||||||
define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
|
define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// INCLUDES
|
||||||
|
|
||||||
|
if(defined('CUSTOM_INCLUDE_PATH')) {
|
||||||
|
$includePath = CUSTOM_INCLUDE_PATH . PATH_SEPARATOR
|
||||||
|
. FRAMEWORK_PATH . PATH_SEPARATOR
|
||||||
|
. FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR
|
||||||
|
. THIRDPARTY_PATH . PATH_SEPARATOR
|
||||||
|
. get_include_path();
|
||||||
|
} else {
|
||||||
|
$includePath = FRAMEWORK_PATH . PATH_SEPARATOR
|
||||||
|
. FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR
|
||||||
|
. THIRDPARTY_PATH . PATH_SEPARATOR
|
||||||
|
. get_include_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
set_include_path($includePath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the temporary folder if it wasn't defined yet
|
* Define the temporary folder if it wasn't defined yet
|
||||||
*/
|
*/
|
||||||
|
require_once 'core/TempPath.php';
|
||||||
|
|
||||||
if(!defined('TEMP_FOLDER')) {
|
if(!defined('TEMP_FOLDER')) {
|
||||||
define('TEMP_FOLDER', getTempFolder());
|
define('TEMP_FOLDER', getTempFolder(BASE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -212,24 +232,6 @@ mb_regex_encoding('UTF-8');
|
|||||||
*/
|
*/
|
||||||
gc_enable();
|
gc_enable();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// INCLUDES
|
|
||||||
|
|
||||||
if(defined('CUSTOM_INCLUDE_PATH')) {
|
|
||||||
$includePath = CUSTOM_INCLUDE_PATH . PATH_SEPARATOR
|
|
||||||
. FRAMEWORK_PATH . PATH_SEPARATOR
|
|
||||||
. FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR
|
|
||||||
. THIRDPARTY_PATH . PATH_SEPARATOR
|
|
||||||
. get_include_path();
|
|
||||||
} else {
|
|
||||||
$includePath = FRAMEWORK_PATH . PATH_SEPARATOR
|
|
||||||
. FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR
|
|
||||||
. THIRDPARTY_PATH . PATH_SEPARATOR
|
|
||||||
. get_include_path();
|
|
||||||
}
|
|
||||||
|
|
||||||
set_include_path($includePath);
|
|
||||||
|
|
||||||
// Include the files needed the initial manifest building, as well as any files
|
// Include the files needed the initial manifest building, as well as any files
|
||||||
// that are needed for the boostrap process on every request.
|
// that are needed for the boostrap process on every request.
|
||||||
require_once 'cache/Cache.php';
|
require_once 'cache/Cache.php';
|
||||||
@ -301,51 +303,6 @@ function getSysTempDir() {
|
|||||||
return sys_get_temp_dir();
|
return sys_get_temp_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the temporary folder that silverstripe should use for its cache files
|
|
||||||
* This is loaded into the TEMP_FOLDER define on start up
|
|
||||||
*
|
|
||||||
* @param $base The base path to use as the basis for the temp folder name. Defaults to BASE_PATH,
|
|
||||||
* which is usually fine; however, the $base argument can be used to help test.
|
|
||||||
*/
|
|
||||||
function getTempFolder($base = null) {
|
|
||||||
if(!$base) $base = BASE_PATH;
|
|
||||||
$tempPath = '';
|
|
||||||
$worked = true;
|
|
||||||
|
|
||||||
// first, try finding a silverstripe-cache dir built off the base path
|
|
||||||
$tempPath = $base . '/silverstripe-cache';
|
|
||||||
if(@file_exists($tempPath)) {
|
|
||||||
return $tempPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// failing the above, try finding a namespaced silverstripe-cache dir in the system temp
|
|
||||||
$cacheFolder = '/silverstripe-cache' . str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
|
||||||
$tempPath = sys_get_temp_dir() . $cacheFolder;
|
|
||||||
if(!@file_exists($tempPath)) {
|
|
||||||
$worked = @mkdir($tempPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// failing to use the system path, attempt to create a local silverstripe-cache dir
|
|
||||||
if(!$worked) {
|
|
||||||
$worked = true;
|
|
||||||
$tempPath = $base . '/silverstripe-cache';
|
|
||||||
if(!@file_exists($tempPath)) {
|
|
||||||
$worked = @mkdir($tempPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$worked) {
|
|
||||||
throw new Exception(
|
|
||||||
'Permission problem gaining access to a temp folder. ' .
|
|
||||||
'Please create a folder named silverstripe-cache in the base folder ' .
|
|
||||||
'of the installation and ensure it has the correct permissions'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tempPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}.
|
* @deprecated 3.0 Please use {@link SS_ClassManifest::getItemPath()}.
|
||||||
*/
|
*/
|
||||||
|
46
core/TempPath.php
Normal file
46
core/TempPath.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Returns the temporary folder path that silverstripe should use for its cache files.
|
||||||
|
*
|
||||||
|
* @param $base The base path to use for determining the temporary path
|
||||||
|
* @return string Path to temp
|
||||||
|
*/
|
||||||
|
function getTempFolder($base = null) {
|
||||||
|
if(!$base && defined('BASE_PATH')) $base = BASE_PATH;
|
||||||
|
|
||||||
|
$tempPath = '';
|
||||||
|
$worked = true;
|
||||||
|
|
||||||
|
// first, try finding a silverstripe-cache dir built off the base path
|
||||||
|
$tempPath = $base . '/silverstripe-cache';
|
||||||
|
if(@file_exists($tempPath)) {
|
||||||
|
return $tempPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// failing the above, try finding a namespaced silverstripe-cache dir in the system temp
|
||||||
|
$cacheFolder = '/silverstripe-cache' . str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
||||||
|
$tempPath = sys_get_temp_dir() . $cacheFolder;
|
||||||
|
if(!@file_exists($tempPath)) {
|
||||||
|
$worked = @mkdir($tempPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// failing to use the system path, attempt to create a local silverstripe-cache dir
|
||||||
|
if(!$worked) {
|
||||||
|
$worked = true;
|
||||||
|
$tempPath = $base . '/silverstripe-cache';
|
||||||
|
if(!@file_exists($tempPath)) {
|
||||||
|
$worked = @mkdir($tempPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$worked) {
|
||||||
|
throw new Exception(
|
||||||
|
'Permission problem gaining access to a temp folder. ' .
|
||||||
|
'Please create a folder named silverstripe-cache in the base folder ' .
|
||||||
|
'of the installation and ensure it has the correct permissions'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tempPath;
|
||||||
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ class CoreTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testGetTempPathInProject() {
|
public function testGetTempPathInProject() {
|
||||||
if(file_exists($this->tempPath)) {
|
if(file_exists($this->tempPath)) {
|
||||||
$this->assertEquals(getTempFolder(), $this->tempPath);
|
$this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath);
|
||||||
} else {
|
} else {
|
||||||
// A typical Windows location for where sites are stored on IIS
|
// A typical Windows location for where sites are stored on IIS
|
||||||
$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
|
$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
|
||||||
|
7
thirdparty/tinymce/tiny_mce_gzip.php
vendored
7
thirdparty/tinymce/tiny_mce_gzip.php
vendored
@ -9,12 +9,17 @@
|
|||||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$frameworkPath = rtrim(dirname(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR);
|
||||||
|
$basePath = rtrim(dirname($frameworkPath), DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
require_once $frameworkPath . '/core/TempPath.php';
|
||||||
|
|
||||||
// Handle incoming request if it's a script call
|
// Handle incoming request if it's a script call
|
||||||
if (TinyMCE_Compressor::getParam("js")) {
|
if (TinyMCE_Compressor::getParam("js")) {
|
||||||
// Default settings
|
// Default settings
|
||||||
$tinyMCECompressor = new TinyMCE_Compressor(array(
|
$tinyMCECompressor = new TinyMCE_Compressor(array(
|
||||||
// CUSTOM SilverStripe
|
// CUSTOM SilverStripe
|
||||||
'cache_dir' => sys_get_temp_dir()
|
'cache_dir' => getTempFolder($basePath)
|
||||||
// CUSTOM END
|
// CUSTOM END
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user