summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-02-07 17:16:48 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-02-07 17:16:48 +0000
commita3704c8dd8b12a64e2da4b269e576c4d56685da5 (patch)
tree0eee21e300d1e624b584e44253ed41a3e6d6c57c /core
parent8a738ed241d2c3d970f28883f8a0cc5e68ea7ad0 (diff)
Assign the Album|Photo path field explicitly instead of hiding that in
the item::__set magic method.
Diffstat (limited to 'core')
-rw-r--r--core/helpers/album.php4
-rw-r--r--core/helpers/photo.php6
-rw-r--r--core/models/item.php10
3 files changed, 7 insertions, 13 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index c45b9bd8..41d90013 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -30,9 +30,10 @@ class album_Core {
* @param string $name the name of this new album (it will become the directory name on disk)
* @param integer $title the title of the new album
* @param string $description (optional) the longer description of this album
+ * @param string $path (optional) the name to use as the filesystem path component
* @return Item_Model
*/
- static function create($parent, $name, $title, $description=null, $owner_id=null) {
+ static function create($parent, $name, $title, $description=null, $path=null, $owner_id=null) {
if (!$parent->loaded || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
@@ -42,6 +43,7 @@ class album_Core {
$album->title = $title;
$album->description = $description;
$album->name = $name;
+ $album->path = !empty($path) ? $path : preg_replace("/[^A-Za-z0-9\.\-_]/", "_", $name);
$album->owner_id = $owner_id;
$album->thumb_dirty = 1;
$album->resize_dirty = 1;
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index 349e8760..9f784c89 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -31,10 +31,11 @@ class photo_Core {
* @param string $name the filename to use for this photo in the album
* @param integer $title the title of the new photo
* @param string $description (optional) the longer description of this photo
+ * @param string $path (optional) the name to use as the file system path component
* @return Item_Model
*/
- static function create($parent, $filename, $name, $title,
- $description=null, $owner_id=null) {
+ static function create($parent, $filename, $name, $title, $description=null, $path=null,
+ $owner_id=null) {
if (!$parent->loaded || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
@@ -59,6 +60,7 @@ class photo_Core {
$photo->title = $title;
$photo->description = $description;
$photo->name = $name;
+ $photo->path = !empty($path) ? $path : preg_replace("/[^A-Za-z0-9\.\-_]/", "_", $name);
$photo->owner_id = $owner_id;
$photo->width = $image_info[0];
$photo->height = $image_info[1];
diff --git a/core/models/item.php b/core/models/item.php
index e188e0a3..7086625f 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -242,16 +242,6 @@ class Item_Model extends ORM_MPTT {
}
/**
- * @see ORM::__get()
- */
- public function __set($column, $value) {
- if ($column == "name") {
- parent::__set("path", preg_replace("/[^A-Za-z0-9\.\-_]/", "_", $value));
- }
- parent::__set($column, $value);
- }
-
- /**
* @see ORM::save()
*/
public function save() {