Skip to content

Commit

Permalink
FEATURE: allow you to disable ?m suffixing of requirements
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@74326 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Will Rossiter authored and Sam Minnee committed Feb 2, 2011
1 parent 672d68a commit fbdabff
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions core/Requirements.php
Expand Up @@ -7,12 +7,14 @@
* @subpackage view
*/
class Requirements {

/**
* Enable combining of css/javascript files.
*
* @var boolean
*/
private static $combined_files_enabled = true;

public static function set_combined_files_enabled($enable) {
self::$combined_files_enabled = (bool) $enable;
}
Expand All @@ -21,6 +23,34 @@ public static function get_combined_files_enabled() {
return self::$combined_files_enabled;
}

/**
* Do we want requirements to suffix onto the requirement link
* tags for caching or is it disabled. Getter / Setter available
* through {@link Requirements::set_suffix_requirements()}
*
* @var bool
*/
private static $suffix_requirements = true;

/**
* Set whether we want to suffix requirements with the time /
* location on to the requirements
*
* @param bool
*/
public static function set_suffix_requirements($var) {
self::$suffix_requirements = $var;
}

/**
* Return whether we want to suffix requirements
*
* @return bool
*/
public static function get_suffix_requirements() {
return self::$suffix_requirements;
}

/**
* Instance of requirements for storage
*
Expand Down Expand Up @@ -321,7 +351,7 @@ class Requirements_Backend {
* @var array $disabled
*/
protected $disabled = array();

/**
* The filepaths (relative to webroot) or
* uniquenessIDs of any included requirements
Expand Down Expand Up @@ -672,7 +702,10 @@ protected static function path_for_file($fileOrUrl) {
return $fileOrUrl;
} elseif(Director::fileExists($fileOrUrl)) {
$prefix = Director::absoluteBaseURL();
$mtimesuffix = "?m=" . filemtime(Director::baseFolder() . '/' . $fileOrUrl);
$mtimesuffix = "";
if(Requirements::get_suffix_requirements()) {
$mtimesuffix = "?m=" . filemtime(Director::baseFolder() . '/' . $fileOrUrl);
}
return "{$prefix}{$fileOrUrl}{$mtimesuffix}";
} else {
return false;
Expand Down

0 comments on commit fbdabff

Please sign in to comment.