Skip to content

Commit

Permalink
Merge pull request #1 from sb-relaxt-at/master
Browse files Browse the repository at this point in the history
refactor code to use base class implementation
  • Loading branch information
axyr committed Oct 25, 2014
2 parents d81493b + 48bc619 commit 0854a10
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions code/ModuleRequirements_Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,12 @@ class ModuleRequirements_Backend extends Requirements_Backend {

protected function path_for_file($fileOrUrl) {
if(preg_match('{^//|http[s]?}', $fileOrUrl)) {
return $fileOrUrl;

return $fileOrUrl;
} else {
if(!Director::fileExists($fileOrUrl)) {
$fileOrUrl = MODULES_DIR . '/' . $fileOrUrl;
}
if(Director::fileExists($fileOrUrl)) {
$filePath = preg_replace('/\?.*/', '', Director::baseFolder() . '/' . $fileOrUrl);
$prefix = Director::baseURL();
$mtimesuffix = "";
$suffix = '';
if($this->suffix_requirements) {
$mtimesuffix = "?m=" . filemtime($filePath);
$suffix = '&';
}
if(strpos($fileOrUrl, '?') !== false) {
if (strlen($suffix) == 0) {
$suffix = '?';
}
$suffix .= substr($fileOrUrl, strpos($fileOrUrl, '?')+1);
$fileOrUrl = substr($fileOrUrl, 0, strpos($fileOrUrl, '?'));
} else {
$suffix = '';
}
return "{$prefix}{$fileOrUrl}{$mtimesuffix}{$suffix}";
} else {
return false;
}
return parent::path_for_file($fileOrUrl);
}
}
}

0 comments on commit 0854a10

Please sign in to comment.