MINOR Using ASSETS_DIR and THEMES_DIR constant in Image, ManifestBuilder, Requirements, File (fixes #5619)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@105282 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-05-20 21:29:59 +00:00 committed by Sam Minnee
parent 24b365d4e2
commit 0742a38732
4 changed files with 20 additions and 11 deletions

View File

@ -219,8 +219,8 @@ class ManifestBuilder {
// Skip certain directories
if($filename[0] == '.') continue;
if($filename == 'themes') continue;
if($filename == 'assets') continue;
if($filename == THEMES_DIR) continue;
if($filename == ASSETS_DIR) continue;
if(in_array($filename, $excludedFolders)) continue;
if(@is_dir("$baseDir/$filename") &&
@ -246,7 +246,7 @@ class ManifestBuilder {
$themeDirs = self::get_themes("$baseDir/themes", true);
foreach($themeDirs as $themeDir) {
$themeName = strtok($themeDir, '_');
ManifestBuilder::getTemplateManifest($baseDir, "themes/$themeDir", $excludedFolders, $templateManifest, $cssManifest, $themeName);
ManifestBuilder::getTemplateManifest($baseDir, THEMES_DIR . "/$themeDir", $excludedFolders, $templateManifest, $cssManifest, $themeName);
}
}

View File

@ -395,11 +395,10 @@ class Requirements_Backend {
public $combine_js_with_jsmin = true;
/**
* By default, combined files are stored in assets/_combinedfiles.
* @var string By default, combined files are stored in assets/_combinedfiles.
* Set this by calling Requirements::set_combined_files_folder()
* @var string
*/
protected $combinedFilesFolder = 'assets/_combinedfiles';
protected $combinedFilesFolder = null;
/**
* Put all javascript includes at the bottom of the template
@ -424,10 +423,20 @@ class Requirements_Backend {
return $this->combined_files_enabled;
}
/**
* @param String $folder
*/
function setCombinedFilesFolder($folder) {
$this->combinedFilesFolder = $folder;
}
/**
* @return String Folder relative to the webroot
*/
function getCombinedFilesFolder() {
return ($this->combinedFilesFolder) ? $this->combinedFilesFolder : ASSETS_DIR . '/_combinedfiles';
}
/**
* Set whether we want to suffix requirements with the time /
* location on to the requirements
@ -849,7 +858,7 @@ class Requirements_Backend {
*/
function delete_combined_files($combinedFileName = null) {
$combinedFiles = ($combinedFileName) ? array($combinedFileName => null) : $this->combine_files;
$combinedFolder = ($this->combinedFilesFolder) ? (Director::baseFolder() . '/' . $this->combinedFilesFolder) : Director::baseFolder();
$combinedFolder = ($this->getCombinedFilesFolder()) ? (Director::baseFolder() . '/' . $this->combinedFilesFolder) : Director::baseFolder();
foreach($combinedFiles as $combinedFile => $sourceItems) {
$filePath = $combinedFolder . '/' . $combinedFile;
if(file_exists($filePath)) {
@ -889,7 +898,7 @@ class Requirements_Backend {
}
// Work out the relative URL for the combined files from the base folder
$combinedFilesFolder = ($this->combinedFilesFolder) ? ($this->combinedFilesFolder . '/') : '';
$combinedFilesFolder = ($this->getCombinedFilesFolder()) ? ($this->getCombinedFilesFolder() . '/') : '';
// Figure out which ones apply to this pageview
$combinedFiles = array();
@ -917,7 +926,7 @@ class Requirements_Backend {
$base = Director::baseFolder() . '/';
foreach(array_diff_key($combinedFiles, $this->blocked) as $combinedFile => $dummy) {
$fileList = $this->combine_files[$combinedFile];
$combinedFilePath = $base . $this->combinedFilesFolder . '/' . $combinedFile;
$combinedFilePath = $base . $combinedFilesFolder . '/' . $combinedFile;
// Make the folder if necessary

View File

@ -333,7 +333,7 @@ class Image extends File {
$methodNames = $this->allMethodNames();
$cachedFiles = array();
$folder = $this->ParentID ? $this->Parent()->Filename : 'assets/';
$folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . '/';
$cacheDir = Director::getAbsFile($folder . '_resampled/');
if(is_dir($cacheDir)) {

View File

@ -87,7 +87,7 @@ class File extends DataObject {
$item = null;
foreach($parts as $part) {
if($part == "assets" && !$parentID) continue;
if($part == ASSETS_DIR && !$parentID) continue;
$SQL_part = Convert::raw2sql($part);
$item = DataObject::get_one("File", "\"Name\" = '$SQL_part' AND \"ParentID\" = $parentID");
if(!$item) break;