commit 61bbbc7c196e2ca7a3a52d8fa36f302cac9b28dd
parent 2275c99f386f07c438b1608ac636d5465ef0ad74
Author: felicitus <felicitus@felicitus.org>
Date: Tue, 27 Dec 2011 18:01:18 +0100
Use default directory for data and images if none was set
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Image/Image.php b/src/backend/de/RaumZeitLabor/PartKeepr/Image/Image.php
@@ -83,7 +83,9 @@ abstract class Image extends UploadedFile {
* @return string The path to the image
*/
public function getFilePath () {
- return Configuration::getOption("partkeepr.images.path").$this->getType()."/";
+ return Configuration::getOption(
+ "partkeepr.images.path",
+ PartKeepr::getRootDirectory() . "/data/images/") . $this->getType() . "/";
}
/**
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/UploadedFile/UploadedFile.php b/src/backend/de/RaumZeitLabor/PartKeepr/UploadedFile/UploadedFile.php
@@ -214,7 +214,9 @@ abstract class UploadedFile extends BaseEntity {
* @return string The path to the file
*/
public function getFilePath () {
- return Configuration::getOption("partkeepr.files.path").$this->getType()."/";
+ return Configuration::getOption(
+ "partkeepr.files.path",
+ PartKeepr::getRootDirectory() . "/data/") . $this->getType() . "/";
}
/**
@@ -228,7 +230,11 @@ abstract class UploadedFile extends BaseEntity {
*/
public function ensureFilePathExists () {
if (!is_dir($this->getFilePath())) {
- mkdir($this->getFilePath(), 0777, true);
+ try {
+ mkdir($this->getFilePath(), 0777, true);
+ } catch (\Exception $e) {
+ throw new \Exception("Unable to create directory ".$this->getFilePath());
+ }
}
}