diff options
author | emkael <emkael@tlen.pl> | 2016-04-06 11:33:07 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-04-06 11:33:07 +0200 |
commit | ea7924464b41d6754864f4dd08121db6c7eec0b1 (patch) | |
tree | 788ed968576275173b92a8cbd1fda3041bf07a13 /app/php/model/Calendar.php | |
parent | e8c7ef440c0961118992dc24cc96c77fd1532d01 (diff) |
* path generation for uploaded calendar images
Diffstat (limited to 'app/php/model/Calendar.php')
-rw-r--r-- | app/php/model/Calendar.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/php/model/Calendar.php b/app/php/model/Calendar.php index 23a0818..4edf2a2 100644 --- a/app/php/model/Calendar.php +++ b/app/php/model/Calendar.php @@ -63,6 +63,25 @@ class Calendar extends ActiveRecord { } } + public function getCustomImagePath($forFile = NULL, $type = '') { + $pathParts = [ + Prado::getApplication()->getBasePath(), + self::CUSTOM_IMAGE_PATH + ]; + if ($forFile) { + $pathParts[] = $this->_getCustomImageHash($forFile, $type); + } + return implode(DIRECTORY_SEPARATOR, $pathParts); + } + + private function _getCustomImageHash($file, $type) { + $hash = md5($file . md5_file($file) . filemtime($file)); + if ($type) { + $hash .= '.' . preg_replace('#^image/#', '', $type); + } + return $hash; + } + } ?> |