aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2009-08-24 11:57:49 +0000
committerCash Costello <cash.costello@gmail.com>2009-08-24 11:57:49 +0000
commit9b3063648c91efe04a96c6c9293e130e6b0b58a0 (patch)
tree5d6780c3fb4ecca0aa2d16835e1060134aafd8b7
parentca9a2ca2593903c7fc2b569e4338408143c71609 (diff)
downloadelgg-9b3063648c91efe04a96c6c9293e130e6b0b58a0.tar.gz
elgg-9b3063648c91efe04a96c6c9293e130e6b0b58a0.tar.bz2
moving tagging code into TidypicsImage class
-rw-r--r--lib/image.php47
-rw-r--r--views/default/object/image.php41
2 files changed, 54 insertions, 34 deletions
diff --git a/lib/image.php b/lib/image.php
index 3a23a1932..cb4182f01 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -18,6 +18,53 @@
{
parent::__construct($guid);
}
+
+ public function getPhotoTags()
+ {
+ // get tags as annotations
+ $photo_tags = get_annotations($this->getGUID(), 'object', 'image', 'phototag');
+ if (!$photo_tags)
+ {
+ // no tags or user doesn't have permission to tags, so return
+ return false;
+ }
+
+ $photo_tags_json = "[";
+ foreach ($photo_tags as $p)
+ {
+ $photo_tag = unserialize($p->value);
+
+ // create link to page with other photos tagged with same tag
+ $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;
+ }
+
+ if (isset($photo_tag->x1)) {
+ // hack to handle format of Pedro Prez's tags - ugh
+ $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 = rtrim($photo_tags_json,',');
+ $photo_tags_json .= ']';
+
+ $rt = array('raw' => $photo_tags, 'json' => $photo_tags_json, 'links' => $photo_tag_links);
+ return $rt;
+ }
}
?> \ No newline at end of file
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 .= ']';
-}
-
/********************************************************************
*