]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #15. Added untagging.
authorBrett Profitt <brett.profitt@gmail.com>
Sat, 18 Feb 2012 01:26:45 +0000 (17:26 -0800)
committerBrett Profitt <brett.profitt@gmail.com>
Sat, 18 Feb 2012 01:26:45 +0000 (17:26 -0800)
actions/photos/image/untag.php [new file with mode: 0644]
classes/TidypicsImage.php
languages/en.php
start.php
views/default/js/photos/tagging.php
views/default/photos/tagging/tag.php

diff --git a/actions/photos/image/untag.php b/actions/photos/image/untag.php
new file mode 100644 (file)
index 0000000..012f989
--- /dev/null
@@ -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);
index b97a2b05e59509c6e203bed4dd9504600c69b645..a6474301791004819f48a43d75c90c2eaf5c004d 100644 (file)
@@ -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;
index 69ba9d24575c128dc98050ec71be5e03ce367daf..efae155b36ee80ae3aee9b7d45caae14631f7020 100644 (file)
@@ -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.                     
                        
index a2dc75ab184a97686c2175692149b5022d79475d..6ef3af5412d16cef7869e54d3dd4a3852c4e0e6a 100644 (file)
--- a/start.php
+++ b/start.php
@@ -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');
index a3c7efc1ca5d15c0814e92a693293cf49c97fe25..f444aa44c863596aa597732ecbc5828323ef6ebc 100644 (file)
@@ -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();
+
 };
 
 /**
index 93ea1621898121ea4a8c1d9f052559a5057dfd4a..6f6af968a1d6eb42a446ff611d308d0645abe01a 100644 (file)
@@ -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;