diff options
Diffstat (limited to 'app/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; + } + } ?> |