summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-04-06 11:33:07 +0200
committeremkael <emkael@tlen.pl>2016-04-06 11:33:07 +0200
commitea7924464b41d6754864f4dd08121db6c7eec0b1 (patch)
tree788ed968576275173b92a8cbd1fda3041bf07a13 /app
parente8c7ef440c0961118992dc24cc96c77fd1532d01 (diff)
* path generation for uploaded calendar images
Diffstat (limited to 'app')
-rw-r--r--app/php/model/Calendar.php19
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;
+ }
+
}
?>