From 9b3063648c91efe04a96c6c9293e130e6b0b58a0 Mon Sep 17 00:00:00 2001
From: Cash Costello <cash.costello@gmail.com>
Date: Mon, 24 Aug 2009 11:57:49 +0000
Subject: moving tagging code into TidypicsImage class

---
 views/default/object/image.php | 41 +++++++----------------------------------
 1 file changed, 7 insertions(+), 34 deletions(-)

(limited to 'views/default')

diff --git a/views/default/object/image.php b/views/default/object/image.php
index 852fea8db..10c89459b 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -20,41 +20,14 @@
 
 /////////////////////////////////////////////////////
 // get photo tags from database
-$photo_tags_json = "\"\"";
-$photo_tags = get_annotations($file_guid,'object','image','phototag');
-
-if ($photo_tags) {
-	$photo_tags_json = "[";
-	foreach ($photo_tags as $p) {
-		$photo_tag = unserialize($p->value);
-		
-
-		$phototag_text = $photo_tag->value;
-		$phototag_link = $vars['url'] . 'search/?tag=' . $phototag_text . '&amp;subtype=image&amp;object=object';
-		if ($photo_tag->type === 'user') {
-			$user = get_entity($photo_tag->value);
-			if ($user)
-				$phototag_text = $user->name;
-			else
-				$phototag_text = "unknown user";
-			
-			$phototag_link = $vars['url'] . "pg/photos/tagged/" . $photo_tag->value;
-		}
-
-		// hack to handle format of Pedro Prez's tags - ugh
-		if (isset($photo_tag->x1)) {
-			$photo_tag->coords = "\"x1\":\"{$photo_tag->x1}\",\"y1\":\"{$photo_tag->y1}\",\"width\":\"{$photo_tag->width}\",\"height\":\"{$photo_tag->height}\""; 
-			$photo_tags_json .= '{' . $photo_tag->coords . ',"text":"' . $phototag_text . '","id":"' . $p->id . '"},';
-		} else
-			$photo_tags_json .= '{' . $photo_tag->coords . ',"text":"' . $phototag_text . '","id":"' . $p->id . '"},';
-		
-		// prepare variable arrays for tagging view
-		$photo_tag_links[$p->id] = array($phototag_text, $phototag_link);
+	$photo_tags_json = "\"\"";
+	
+	$tag_info = $file->getPhotoTags();
+	if ($tag_info) {
+		$photo_tags = $tag_info['raw'];
+		$photo_tags_json = $tag_info['json'];
+		$photo_tag_links = $tag_info['links'];
 	}
-	$photo_tags_json = rtrim($photo_tags_json,',');
-	$photo_tags_json .= ']';
-}
-
 
 /********************************************************************
  *
-- 
cgit v1.2.3