aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/deletetag.php51
-rw-r--r--languages/en.php6
-rw-r--r--start.php1
-rw-r--r--views/default/js/tagging.php29
-rw-r--r--views/default/object/image.php6
-rw-r--r--views/default/tidypics/css.php12
-rw-r--r--views/default/tidypics/image_menu.php11
-rw-r--r--views/default/tidypics/tagging.php16
8 files changed, 129 insertions, 3 deletions
diff --git a/actions/deletetag.php b/actions/deletetag.php
new file mode 100644
index 000000000..cd76b0a1d
--- /dev/null
+++ b/actions/deletetag.php
@@ -0,0 +1,51 @@
+<?php
+ /**
+ * Tidypics Delete Photo Tag
+ *
+ */
+
+ gatekeeper();
+ action_gatekeeper();
+
+ //$user_id = get_input('user_id');
+ $image_guid = get_input('image_guid');
+ $tags = get_input('tags');
+
+
+ if ($image_guid == 0) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ $image = get_entity($image_guid);
+ if (!$image)
+ {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+ }
+
+ foreach ($tags as $id => $value) {
+ // delete normal tag if it exists
+ if (is_array($image->tags)) {
+ $index = array_search($value[0], $image->tags);
+ if ($index !== false) {
+ $tagarray = $image->tags;
+ unset($tagarray[$index]);
+ $image->clearMetadata('tags');
+ $image->tags = $tagarray;
+ }
+ } else {
+ if ($value[0] === $image->tags) {
+ $image->clearMetadata('tags');
+ }
+ }
+
+ // delete the photo tag annotation
+ delete_annotation($id);
+ }
+
+ system_message(elgg_echo("tidypics:deletetag:success"));
+
+ forward($_SERVER['HTTP_REFERER']);
+
+?>
diff --git a/languages/en.php b/languages/en.php
index f1f3ed543..7c452c6e4 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -92,12 +92,18 @@
// tagging
'tidypics:taginstruct' => 'Select area that you want to tag',
+ '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:phototagging:success' => 'Photo tag was successfully added',
'tidypics:phototagging:error' => 'Unexpected error occurred during tagging',
+ 'tidypics:deletetag:success' => 'Selected tags were successfully deleted',
+
//widgets
diff --git a/start.php b/start.php
index 2d4d40782..082dc1507 100644
--- a/start.php
+++ b/start.php
@@ -371,5 +371,6 @@
register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php");
register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php");
register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php");
+ register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php");
?> \ No newline at end of file
diff --git a/views/default/js/tagging.php b/views/default/js/tagging.php
index e27af7fca..a79914196 100644
--- a/views/default/js/tagging.php
+++ b/views/default/js/tagging.php
@@ -139,7 +139,7 @@
$('#tag_control').text("Stop Tagging");
showTagInstruct();
-
+ $('#delete_tag_menu').hide();
$('#tidypics_image').hover(
function(){
@@ -252,4 +252,31 @@
//Show loading
//$("#tag_menu").replaceWith('<div align="center" class="ajax_loader"></div>');
}
+
+ function deleteTags()
+ {
+ offsetY = 60;
+
+ divWidth = $('#delete_tag_menu').width();
+ imgOffset = $('#tidypics_image').offset();
+ imgWidth = $('#tidypics_image').width();
+ offsetX = parseInt((imgWidth - divWidth)/2);
+
+ _top = imgOffset.top + offsetY;
+ _left = imgOffset.left + offsetX;
+
+ $('#delete_tag_menu').show().css({
+ "top": _top + "px",
+ "left": _left + "px"
+ });
+
+ $('#tidypics_image').hover(
+ function(){
+ $('.tidypics_tag').hide();
+ },
+ function(){
+ $('.tidypics_tag').hide();
+ }
+ );
+ }
</script> \ No newline at end of file
diff --git a/views/default/object/image.php b/views/default/object/image.php
index 64109f1a2..1ab2e921a 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -47,6 +47,7 @@ if ($photo_tags) {
$photo_tags_json .= '{' . $photo_tag->coords . ',"text":"' . $phototag_text . '","id":"' . $p->id . '"},';
$photo_tag_links[] = array($p->id, $phototag_text); // gave up on associative array for now
+ $photo_tag_texts[$p->id] = $phototag_text;
}
$photo_tags_json = rtrim($photo_tags_json,',');
$photo_tags_json .= ']';
@@ -184,16 +185,19 @@ if ($photo_tags) {
</div>
<?php
// image menu (start tagging, download, etc.)
+
echo '<div id="tidypics_controls"><ul>';
echo elgg_view('tidypics/image_menu', array('file_guid' => $file_guid,
'viewer' => $viewer,
- 'owner' => $owner,) );
+ 'owner' => $owner,
+ 'anytags' => $photo_tags != '',) );
echo '</ul></div>';
// tagging code
if (get_plugin_setting('tagging', 'tidypics') != "disabled") {
echo elgg_view('tidypics/tagging', array( 'photo_tags' => $photo_tags,
'links' => $photo_tag_links,
+ 'text' => $photo_tag_texts,
'photo_tags_json' => $photo_tags_json,
'file_guid' => $file_guid,
'viewer' => $viewer,
diff --git a/views/default/tidypics/css.php b/views/default/tidypics/css.php
index bc0073734..7564f1eaf 100644
--- a/views/default/tidypics/css.php
+++ b/views/default/tidypics/css.php
@@ -230,6 +230,18 @@ font-size:12px;
text-align:left;
}
+#delete_tag_menu {
+border:1px solid #3B5999;
+width:200px;
+position:absolute;
+z-index:10000;
+display:none;
+background:#ffffff;
+padding:10px;
+font-size:12px;
+text-align:left;
+}
+
.tidypics_tag {
display:none;
background:url(<?php echo $vars['url']; ?>mod/tidypics/graphics/spacer.gif);
diff --git a/views/default/tidypics/image_menu.php b/views/default/tidypics/image_menu.php
index 9257d780a..5940a0138 100644
--- a/views/default/tidypics/image_menu.php
+++ b/views/default/tidypics/image_menu.php
@@ -13,7 +13,8 @@
$file_guid = $vars['file_guid'];
$viewer = $vars['viewer'];
$owner = $vars['owner'];
-
+ $anytags = $vars['anytags'];
+
if (get_plugin_setting('tagging', 'tidypics') != "disabled") {
// only owner and friends of owner can tag
if ($viewer && $viewer->guid == $owner->guid || user_is_friend($owner->guid, $viewer->guid)) {
@@ -21,7 +22,15 @@
<li id="start_tagging"><a id="tag_control" href="javascript:void(0)" onclick="startTagging()"><?= elgg_echo('tidypics:tagthisphoto') ?></a></li>
<?php
}
+
+ // only owner can delete tags
+ if ($anytags && $viewer && $viewer->guid == $owner->guid) {
+?>
+<li id="delete_tags"><a href="javascript:void(0)" onclick="deleteTags()"><?= elgg_echo('tidypics:deletetag') ?></a></li>
+<?php
+ }
}
+
if (get_plugin_setting('download_link', 'tidypics') != "disabled") {
?>
<li id="download_image"><a href="<?php echo $vars['url']; ?>action/tidypics/download?file_guid=<?php echo $file_guid; ?>"><?php echo elgg_echo("image:download"); ?></a></li>
diff --git a/views/default/tidypics/tagging.php b/views/default/tidypics/tagging.php
index 8ba58be4f..fdf40b3a5 100644
--- a/views/default/tidypics/tagging.php
+++ b/views/default/tidypics/tagging.php
@@ -5,6 +5,7 @@
$file_guid = $vars['file_guid'];
$viewer = $vars['viewer'];
$owner = $vars['owner'];
+ $tag_texts = $vars['text'];
if ($photo_tags) {
?>
@@ -53,6 +54,21 @@
?>
</div>
+<div id="delete_tag_menu">
<?php
+ if ($photo_tags) {
+ echo elgg_echo('tidypics:deltag_title') . '<br />';
+ $content = "<input type='hidden' name='image_guid' value='{$file_guid}' />";
+ foreach ($tag_texts as $id => $text) {
+ $name = "tags[{$id}]";
+ $content .= elgg_view("input/checkboxes", array('options' => array($text => $text), 'internalname' => $name, 'value' => '' ));
+ }
+ $content .= "<fieldset><button class='submit_button' type='submit'>" . elgg_echo('tidypics:actiondelete') . "</button></fieldset>";
+
+ echo elgg_view('input/form', array('internalname' => 'form-deletetag', 'action' => "{$vars['url']}action/tidypics/deletetag", 'body' => $content));
+
+ }
+ echo '</div>'; // delete_tag_menu
+
echo elgg_view('js/tagging', array('photo_tags_json' => $photo_tags_json,) );
?> \ No newline at end of file