From ea7924464b41d6754864f4dd08121db6c7eec0b1 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 6 Apr 2016 11:33:07 +0200 Subject: * path generation for uploaded calendar images --- app/php/model/Calendar.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/php/model/Calendar.php') 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; + } + } ?> -- cgit v1.2.3