Permalink
Browse files

Refactor: moved relations from photo object to new photoRelations object

created new object photoRelations and moved all relation-related methods
into it.
  • Loading branch information...
1 parent 058b8c7 commit 289e022fe9a8dcd9be6c9f443412d73d7b3fc699 @jeroenrnl committed Jan 16, 2013
@@ -199,6 +199,7 @@ private static function importTestImages() {
$photographer=testData::getPhotographer();
$comments=testData::getComments();
$ratings=testData::getRatings();
+ $relations=testData::getRelations();
$files=array();
foreach($photos as $id=>$photo) {
@@ -240,6 +241,17 @@ private static function importTestImages() {
$photo->addTo(new person ($pers));
}
}
+ if(isset($relations[$id])) {
+ foreach($relations[$id] as $related => $rel_desc) {
+ photoRelation::defineRelation(
+ $photo,
+ new photo($related),
+ $rel_desc[0],
+ $rel_desc[1]);
+ }
+ }
+
+ // WARNING, below this line other users log in!
if(isset($comments[$id])) {
foreach($comments[$id] as $user_id => $comment) {
$obj = new comment();
@@ -258,6 +270,7 @@ private static function importTestImages() {
$obj->add_comment_to_photo($photo->get("photo_id"));
}
}
+
if(isset($ratings[$id])) {
$total=0;
$count=0;
@@ -278,6 +291,7 @@ private static function importTestImages() {
$avg=$total/$count;
$photo->lookup();
}
+
}
}
@@ -245,6 +245,21 @@ public static function getRatings() {
);
}
+ public static function getRelations() {
+ return array(
+ 1 => array(
+ 2 => array("first photo", "second photo"),
+ 3 => array("first photo", "third photo"),
+ 4 => array("first photo", "fourth photo")),
+ 2 => array(
+ 3 => array("second photo", "third photo")),
+ 5 => array(
+ 4 => array("fifth photo", "fourth photo")),
+ 6 => array(
+ 5 => array("sixth photo", "fifth photo"))
+ );
+ }
+
public static function getComments() {
return array(
1 => array(
Oops, something went wrong.

0 comments on commit 289e022

Please sign in to comment.