Skip to content

Commit

Permalink
MINOR Using ASSETS_DIR and THEMES_DIR constant in Image, ManifestBuil…
Browse files Browse the repository at this point in the history
…der, Requirements, File (fixes #5619) (from r105282)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112493 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Oct 15, 2010
1 parent a3cf47f commit 2943c75
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions core/ManifestBuilder.php
Expand Up @@ -219,8 +219,8 @@ static function get_manifest_info($baseDir, $excludedFolders = array()) {


// Skip certain directories // Skip certain directories
if($filename[0] == '.') continue; if($filename[0] == '.') continue;
if($filename == 'themes') continue; if($filename == THEMES_DIR) continue;
if($filename == 'assets') continue; if($filename == ASSETS_DIR) continue;
if(in_array($filename, $excludedFolders)) continue; if(in_array($filename, $excludedFolders)) continue;


if(@is_dir("$baseDir/$filename") && if(@is_dir("$baseDir/$filename") &&
Expand All @@ -246,7 +246,7 @@ static function get_manifest_info($baseDir, $excludedFolders = array()) {
$themeDirs = self::get_themes("$baseDir/themes", true); $themeDirs = self::get_themes("$baseDir/themes", true);
foreach($themeDirs as $themeDir) { foreach($themeDirs as $themeDir) {
$themeName = strtok($themeDir, '_'); $themeName = strtok($themeDir, '_');
ManifestBuilder::getTemplateManifest($baseDir, "themes/$themeDir", $excludedFolders, $templateManifest, $cssManifest, $themeName); ManifestBuilder::getTemplateManifest($baseDir, THEMES_DIR . "/$themeDir", $excludedFolders, $templateManifest, $cssManifest, $themeName);
} }
} }


Expand Down
21 changes: 15 additions & 6 deletions core/Requirements.php
Expand Up @@ -395,11 +395,10 @@ class Requirements_Backend {
public $combine_js_with_jsmin = true; 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() * 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 * Put all javascript includes at the bottom of the template
Expand All @@ -424,10 +423,20 @@ function get_combined_files_enabled() {
return $this->combined_files_enabled; return $this->combined_files_enabled;
} }


/**
* @param String $folder
*/
function setCombinedFilesFolder($folder) { function setCombinedFilesFolder($folder) {
$this->combinedFilesFolder = $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 / * Set whether we want to suffix requirements with the time /
* location on to the requirements * location on to the requirements
Expand Down Expand Up @@ -849,7 +858,7 @@ function get_combine_files() {
*/ */
function delete_combined_files($combinedFileName = null) { function delete_combined_files($combinedFileName = null) {
$combinedFiles = ($combinedFileName) ? array($combinedFileName => null) : $this->combine_files; $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) { foreach($combinedFiles as $combinedFile => $sourceItems) {
$filePath = $combinedFolder . '/' . $combinedFile; $filePath = $combinedFolder . '/' . $combinedFile;
if(file_exists($filePath)) { if(file_exists($filePath)) {
Expand Down Expand Up @@ -889,7 +898,7 @@ function process_combined_files() {
} }


// Work out the relative URL for the combined files from the base folder // 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 // Figure out which ones apply to this pageview
$combinedFiles = array(); $combinedFiles = array();
Expand Down Expand Up @@ -917,7 +926,7 @@ function process_combined_files() {
$base = Director::baseFolder() . '/'; $base = Director::baseFolder() . '/';
foreach(array_diff_key($combinedFiles, $this->blocked) as $combinedFile => $dummy) { foreach(array_diff_key($combinedFiles, $this->blocked) as $combinedFile => $dummy) {
$fileList = $this->combine_files[$combinedFile]; $fileList = $this->combine_files[$combinedFile];
$combinedFilePath = $base . $this->combinedFilesFolder . '/' . $combinedFile; $combinedFilePath = $base . $combinedFilesFolder . '/' . $combinedFile;




// Make the folder if necessary // Make the folder if necessary
Expand Down
2 changes: 1 addition & 1 deletion core/model/Image.php
Expand Up @@ -333,7 +333,7 @@ public function deleteFormattedImages() {
$methodNames = $this->allMethodNames(); $methodNames = $this->allMethodNames();
$cachedFiles = array(); $cachedFiles = array();


$folder = $this->ParentID ? $this->Parent()->Filename : 'assets/'; $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . '/';
$cacheDir = Director::getAbsFile($folder . '_resampled/'); $cacheDir = Director::getAbsFile($folder . '_resampled/');


if(is_dir($cacheDir)) { if(is_dir($cacheDir)) {
Expand Down
2 changes: 1 addition & 1 deletion filesystem/File.php
Expand Up @@ -87,7 +87,7 @@ static function find($filename) {
$item = null; $item = null;


foreach($parts as $part) { foreach($parts as $part) {
if($part == "assets" && !$parentID) continue; if($part == ASSETS_DIR && !$parentID) continue;
$SQL_part = Convert::raw2sql($part); $SQL_part = Convert::raw2sql($part);
$item = DataObject::get_one("File", "\"Name\" = '$SQL_part' AND \"ParentID\" = $parentID"); $item = DataObject::get_one("File", "\"Name\" = '$SQL_part' AND \"ParentID\" = $parentID");
if(!$item) break; if(!$item) break;
Expand Down

0 comments on commit 2943c75

Please sign in to comment.