diff options
-rw-r--r-- | actions/photos/image/untag.php | 24 | ||||
-rw-r--r-- | classes/TidypicsImage.php | 4 | ||||
-rw-r--r-- | languages/en.php | 11 | ||||
-rw-r--r-- | start.php | 2 | ||||
-rw-r--r-- | views/default/js/photos/tagging.php | 13 | ||||
-rw-r--r-- | views/default/photos/tagging/tag.php | 16 |
6 files changed, 58 insertions, 12 deletions
diff --git a/actions/photos/image/untag.php b/actions/photos/image/untag.php new file mode 100644 index 000000000..012f98930 --- /dev/null +++ b/actions/photos/image/untag.php @@ -0,0 +1,24 @@ +<?php +/** + * Remove photo tag action + */ + +$annotation = get_annotation(get_input('annotation_id')); + +if (!$annotation instanceof ElggAnnotation || $annotation->name != 'phototag') { + register_error(elgg_echo("tidypics:phototagging:delete:error")); + forward(REFERER); +} + +if (!$annotation->canEdit()) { + register_error(elgg_echo("tidypics:phototagging:delete:error")); + forward(REFERER); +} + +if ($annotation->delete()) { + system_message(elgg_echo("tidypics:phototagging:delete:success")); +} else { + system_message(elgg_echo("tidypics:phototagging:delete:error")); +} + +forward(REFERER); diff --git a/classes/TidypicsImage.php b/classes/TidypicsImage.php index b97a2b05e..a64743017 100644 --- a/classes/TidypicsImage.php +++ b/classes/TidypicsImage.php @@ -348,7 +348,9 @@ class TidypicsImage extends ElggFile { 'annotation_name' => 'phototag', )); foreach ($annotations as $annotation) { - $tags[] = unserialize($annotation->value); + $tag = unserialize($annotation->value); + $tag->annotation_id = $annotation->id; + $tags[] = $tag; } return $tags; diff --git a/languages/en.php b/languages/en.php index 69ba9d245..efae155b3 100644 --- a/languages/en.php +++ b/languages/en.php @@ -187,18 +187,21 @@ $english = array( // tagging 'tidypics:taginstruct' => 'Select the area that you want to tag or %s', - 'tidypics:deltag_title' => 'Select tags to delete', 'tidypics:finish_tagging' => 'Stop tagging', 'tidypics:tagthisphoto' => 'Tag this photo', - 'tidypics:deletetag' => 'Delete a photo tag', 'tidypics:actiontag' => 'Tag', - 'tidypics:actiondelete' => 'Delete', 'tidypics:actioncancel' => 'Cancel', 'tidypics:inthisphoto' => 'In this photo', 'tidypics:usertag' => "Photos tagged with user %s", 'tidypics:phototagging:success' => 'Photo tag was successfully added', 'tidypics:phototagging:error' => 'Unexpected error occurred during tagging', - 'tidypics:deletetag:success' => 'Selected tags were successfully deleted', + + 'tidypics:phototagging:delete:success' => 'Photo tag was removed.', + 'tidypics:phototagging:delete:error' => 'Unexpceted error occurred when removing photo tag.', + 'tidypics:phototagging:delete:confirm' => 'Remove this tag?', + + + 'tidypics:tag:subject' => "You have been tagged in a photo", 'tidypics:tag:body' => "You have been tagged in the photo %s by %s. @@ -98,7 +98,7 @@ function tidypics_init() { //register_action("tidypics/ajax_upload", true, "$base_dir/ajax_upload.php"); //register_action("tidypics/ajax_upload_complete", true, "$base_dir/ajax_upload_complete.php"); elgg_register_action("photos/image/tag", "$base_dir/image/tag.php"); - //register_action("tidypics/deletetag", false, "$base_dir/deletetag.php"); + elgg_register_action("photos/image/untag", "$base_dir/image/untag.php"); elgg_register_action("photos/admin/settings", "$base_dir/admin/settings.php", 'admin'); elgg_register_action("photos/admin/create_thumbnails", "$base_dir/admin/create_thumbnails.php", 'admin'); diff --git a/views/default/js/photos/tagging.php b/views/default/js/photos/tagging.php index a3c7efc1c..f444aa44c 100644 --- a/views/default/js/photos/tagging.php +++ b/views/default/js/photos/tagging.php @@ -7,7 +7,7 @@ */ ?> - +//<script> elgg.provide('elgg.tidypics.tagging'); elgg.tidypics.tagging.init = function() { @@ -82,10 +82,13 @@ elgg.tidypics.tagging.startSelect = function(img, selection) { coords += '"height":"' + selection.height + '"'; $("input[name=coordinates]").val(coords); - $('#tidypics-tagging-select').show().css({ - 'top' : selection.y2 + 10, - 'left' : selection.x2 - }); + $('#tidypics-tagging-select').show() + .css({ + 'top' : selection.y2 + 10, + 'left' : selection.x2 + }) + .find('input[type=text]').focus(); + }; /** diff --git a/views/default/photos/tagging/tag.php b/views/default/photos/tagging/tag.php index 93ea16218..6f6af968a 100644 --- a/views/default/photos/tagging/tag.php +++ b/views/default/photos/tagging/tag.php @@ -28,9 +28,23 @@ if ($vars['tag']->type == 'user') { $label = $vars['tag']->value; } +$delete = ''; +$annotation = get_annotation($vars['tag']->annotation_id); + +if ($annotation->canEdit()) { + $url = elgg_http_add_url_query_elements('action/photos/image/untag', array( + 'annotation_id' => $vars['tag']->annotation_id + )); + $delete = elgg_view('output/confirmlink', array( + 'href' => $url, + 'text' => elgg_view_icon('delete', 'float mas'), + 'confirm' => elgg_echo('tidypics:phototagging:delete:confirm') + )); +} + echo <<<HTML <div class="tidypics-tag-wrapper"> - <div $attributes></div> + <div $attributes>$delete</div> <div class="elgg-module-popup tidypics-tag-label">$label</div> </div> HTML; |