aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2012-01-02 12:45:16 -0500
committercash <cash.costello@gmail.com>2012-01-02 12:45:16 -0500
commit20ab73de5248b3418bbbad27850e3d3e093c473c (patch)
treecf15a58ad857fbaa4f9b2521c5a7d17ed619f303
parent86535f77d6b32a2c8a403609ded299a76c73bba0 (diff)
downloadelgg-20ab73de5248b3418bbbad27850e3d3e093c473c.tar.gz
elgg-20ab73de5248b3418bbbad27850e3d3e093c473c.tar.bz2
added photo tagging - but not displaying or deleting tags yet
-rw-r--r--actions/photos/image/tag.php (renamed from actions/addtag.php)50
-rw-r--r--languages/en.php4
-rw-r--r--pages/photos/image/view.php5
-rw-r--r--start.php23
-rw-r--r--views/default/forms/photos/image/tag.php33
-rw-r--r--views/default/js/photos/tagging.php73
-rw-r--r--views/default/object/image/full.php4
-rw-r--r--views/default/photos/css.php56
-rw-r--r--views/default/photos/tagging/help.php19
-rw-r--r--views/default/photos/tagging/select.php16
10 files changed, 244 insertions, 39 deletions
diff --git a/actions/addtag.php b/actions/photos/image/tag.php
index 97418f495..0c7ce06ae 100644
--- a/actions/addtag.php
+++ b/actions/photos/image/tag.php
@@ -1,36 +1,32 @@
<?php
/**
- * Tidypics Add Photo Tag
+ * Add photo tag action
*
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
-gatekeeper();
-action_gatekeeper();
-
$coordinates_str = get_input('coordinates');
-
-$user_id = get_input('user_id');
-$image_guid = get_input('image_guid');
-$word = get_input('word');
+$username = get_input('username');
+$image_guid = get_input('guid');
if ($image_guid == 0) {
register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
+ forward(REFERER);
}
$image = get_entity($image_guid);
if (!$image) {
register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
+ forward(REFERER);
}
-// test for empty tag
-if ($user_id == 0 && empty($word)) {
+if (empty($username)) {
register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
+ forward(REFERER);
}
-
+/*
$new_word_tag = false;
if ($user_id != 0) {
$relationships_type = 'user';
@@ -60,24 +56,21 @@ if ($new_word_tag) {
$image->clearMetadata('tags');
$image->tags = $tagarray;
}
+*/
-// create string for javascript tag object
+$tag = new stdClass();
$tag->coords = $coordinates_str;
-$tag->type = $relationships_type;
-$tag->value = $value;
-
+$tag->type = 'user';
+$tag->value = get_user_by_username($username)->getGUID();
$access_id = $image->getAccessID();
-$owner_id = get_loggedin_userid();
-$tagger = get_loggedin_user();
-//Save annotation
-$annotation_id = $image->annotate('phototag', serialize($tag), $access_id, $owner_id);
+$annotation_id = $image->annotate('phototag', serialize($tag), $access_id);
if ($annotation_id) {
// if tag is a user id, add relationship for searching (find all images with user x)
- if ($relationships_type === 'user') {
- if (!check_entity_relationship($user_id, 'phototag', $image_guid)) {
- add_entity_relationship($user_id, 'phototag', $image_guid);
-
+ if ($tag->type === 'user') {
+ if (!check_entity_relationship($tag->value, 'phototag', $image_guid)) {
+ add_entity_relationship($tag->value, 'phototag', $image_guid);
+/*
// also add this to the river - subject is image, object is the tagged user
add_to_river('river/object/image/tag', 'tag', $tagger->guid, $user_id, $access_id, 0, $annotation_id);
@@ -95,11 +88,12 @@ if ($annotation_id) {
)
);
}
+ *
+ */
}
}
system_message(elgg_echo("tidypics:phototagging:success"));
}
-
-forward($_SERVER['HTTP_REFERER']);
+forward(REFERER);
diff --git a/languages/en.php b/languages/en.php
index ec65d0622..2276e4b12 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -45,7 +45,7 @@ $english = array(
'tidypics:friendmostviewed' => "%s's most viewed images",
'tidypics:friendmostrecent' => "%s's most recent images",
'tidypics:highestrated' => "Highest rated images",
- 'tidypics:views' => "Views: %s",
+ 'tidypics:views' => "%s views",
'tidypics:viewsbyowner' => "by %s users (not including you)",
'tidypics:viewsbyothers' => "(%s by you)",
'tidypics:administration' => 'Tidypics Administration',
@@ -129,7 +129,7 @@ $english = array(
'image:index' => "%u of %u",
// tagging
- 'tidypics:taginstruct' => 'Select area that you want to tag',
+ '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',
diff --git a/pages/photos/image/view.php b/pages/photos/image/view.php
index f9157a900..6db9ff529 100644
--- a/pages/photos/image/view.php
+++ b/pages/photos/image/view.php
@@ -17,6 +17,11 @@ if (!$photo) {
$photo->addView();
+if (elgg_get_plugin_setting('tagging', 'tidypics')) {
+ elgg_load_js('tidypics:tagging');
+ elgg_load_js('jquery.imgareaselect');
+}
+
// set page owner based on owner of photo album
$album = $photo->getContainerEntity();
if ($album) {
diff --git a/start.php b/start.php
index 5638037cc..a81c1d854 100644
--- a/start.php
+++ b/start.php
@@ -34,6 +34,9 @@ function tidypics_init() {
$js = elgg_get_simplecache_url('js', 'photos/tidypics');
elgg_register_simplecache_view('js/photos/tidypics');
elgg_register_js('tidypics', $js, 'footer');
+ $js = elgg_get_simplecache_url('js', 'photos/tagging');
+ elgg_register_simplecache_view('js/photos/tagging');
+ elgg_register_js('tidypics:tagging', $js, 'footer');
elgg_register_js('tidypics:slideshow', 'mod/tidypics/vendors/PicLensLite/piclens_optimized.js', 'footer');
// Add photos link to owner block/hover menus
@@ -93,7 +96,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");
//register_action("tidypics/sortalbum", false, "$base_dir/sortalbum.php");
- //register_action("tidypics/addtag", false, "$base_dir/addtag.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/admin/settings", "$base_dir/admin/settings.php", 'admin');
@@ -284,15 +287,27 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) {
if (elgg_instanceof($entity, 'object', 'image')) {
if (elgg_get_plugin_setting('view_count', 'tidypics')) {
$view_info = $entity->getViewInfo();
- $status_text = (int)$view_info['total'] . ' views';
+ $text = elgg_echo('tidypics:views', array((int)$view_info['total']));
$options = array(
- 'name' => 'published_status',
- 'text' => "<span>$status_text</span>",
+ 'name' => 'views',
+ 'text' => "<span>$text</span>",
'href' => false,
'priority' => 90,
);
$return[] = ElggMenuItem::factory($options);
}
+
+ if (elgg_get_plugin_setting('tagging', 'tidypics')) {
+ $options = array(
+ 'name' => 'tagging',
+ 'text' => elgg_echo('tidypics:actiontag'),
+ 'href' => '#',
+ 'title' => elgg_echo('tidypics:tagthisphoto'),
+ 'rel' => 'photo-tagging',
+ 'priority' => 80,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
}
if (elgg_instanceof($entity, 'object', 'album')) {
diff --git a/views/default/forms/photos/image/tag.php b/views/default/forms/photos/image/tag.php
new file mode 100644
index 000000000..31869be9e
--- /dev/null
+++ b/views/default/forms/photos/image/tag.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Tag select form body
+ *
+ * @uses $vars['entity']
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+echo '<div class="elgg-col elgg-col-4of5">';
+
+echo elgg_view('input/autocomplete', array(
+ 'name' => 'username',
+ 'match_on' => 'friends',
+));
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'guid',
+ 'value' => $vars['entity']->getGUID(),
+));
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'coordinates',
+));
+
+echo '</div>';
+
+echo '<div class="elgg-col elgg-col-1of5 center">';
+echo elgg_view('input/submit', array(
+ 'value' => elgg_echo('tidypics:actiontag'),
+));
+echo '</div>';
diff --git a/views/default/js/photos/tagging.php b/views/default/js/photos/tagging.php
new file mode 100644
index 000000000..f831200e7
--- /dev/null
+++ b/views/default/js/photos/tagging.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Photo tagging JavaScript
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+?>
+
+elgg.provide('elgg.tidypics.tagging');
+
+elgg.tidypics.tagging.init = function() {
+ $('[rel=photo-tagging]').click(elgg.tidypics.tagging.start);
+
+ $('#tidypics-tagging-quit').click(elgg.tidypics.tagging.stop);
+}
+
+/**
+ * Start a tagging session
+ */
+elgg.tidypics.tagging.start = function(event) {
+
+ $('.tidypics-photo').imgAreaSelect({
+ disable : false,
+ hide : false,
+ classPrefix : 'tidypics-tagging',
+ onSelectEnd : elgg.tidypics.tagging.startSelect,
+ onSelectStart: function() {
+ $('#tidypics-tagging-select').hide();
+ }
+ });
+
+ $('.tidypics-photo').css({"cursor" : "crosshair"});
+
+ $('#tidypics-tagging-help').toggle();
+
+ event.preventDefault();
+}
+
+/**
+ * Stop tagging
+ *
+ * A tagging session could be completed or the user could have quit.
+ */
+elgg.tidypics.tagging.stop = function(event) {
+ $('#tidypics-tagging-help').toggle();
+ $('#tidypics-tagging-select').hide();
+
+ $('.tidypics-photo').imgAreaSelect({hide: true, disable: true});
+ $('.tidypics-photo').css({"cursor" : "pointer"});
+
+ event.preventDefault();
+}
+
+/**
+ * Start the selection stage of tagging
+ */
+elgg.tidypics.tagging.startSelect = function(img, selection) {
+
+ var coords = '"x1":"' + selection.x1 + '",';
+ coords += '"y1":"' + selection.y1 + '",';
+ coords += '"width":"' + selection.width + '",';
+ coords += '"height":"' + selection.height + '"';
+ $("input[name=coordinates]").val(coords);
+
+ $('#tidypics-tagging-select').show().css({
+ 'top' : selection.y2 + 10,
+ 'left' : selection.x2
+ });
+}
+
+elgg.register_hook_handler('init', 'system', elgg.tidypics.tagging.init);
diff --git a/views/default/object/image/full.php b/views/default/object/image/full.php
index e3a2c7003..33ba49739 100644
--- a/views/default/object/image/full.php
+++ b/views/default/object/image/full.php
@@ -51,8 +51,8 @@ echo $summary;
echo '<div class="tidypics-wrapper-photo">';
echo elgg_view('object/image/navigation', $vars);
-//echo elgg_view('tidypics/tagging/help');
-//echo elgg_view('tidypics/tagging/select', array('photo' => $photo));
+echo elgg_view('photos/tagging/help', $vars);
+echo elgg_view('photos/tagging/select', $vars);
echo $img;
echo '</div>';
diff --git a/views/default/photos/css.php b/views/default/photos/css.php
index 18f225131..31e3d9b53 100644
--- a/views/default/photos/css.php
+++ b/views/default/photos/css.php
@@ -1,9 +1,15 @@
<?php
- /**
- * tidypics CSS extender
- */
+/**
+ * Tidypics CSS
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
?>
+/* ***************************************
+ TIDYPICS
+*************************************** */
.elgg-module-tidypics-album,
.elgg-module-tidypics-image {
width: 161px;
@@ -23,6 +29,10 @@
display: block;
}
+.tidypics-wrapper-photo {
+ position: relative;
+}
+
.tidypics-heading {
color: #0054A7;
}
@@ -66,6 +76,46 @@
vertical-align: top;
}
+/* ***************************************
+ Tagging
+*************************************** */
+.tidypics-tagging-border1 {
+ border: solid 2px white;
+}
+
+.tidypics-tagging-border1, .tidypics-tagging-border2,
+.tidypics-tagging-border3, .tidypics-tagging-border4 {
+ filter: alpha(opacity=50);
+ opacity: 0.5;
+}
+
+.tidypics-tagging-handle {
+ background-color: #fff;
+ border: solid 1px #000;
+ filter: alpha(opacity=50);
+ opacity: 0.5;
+}
+
+.tidypics-tagging-outer {
+ background-color: #000;
+ filter: alpha(opacity=50);
+ opacity: 0.5;
+}
+
+.tidypics-tagging-help {
+ position: absolute;
+ left: 50%;
+ top: -25px;
+ width: 250px;
+ margin-left: -125px;
+ text-align: center;
+}
+
+.tidypics-tagging-select {
+ position: absolute;
+ max-width: 300px;
+}
+
<?php
return true;
?>
diff --git a/views/default/photos/tagging/help.php b/views/default/photos/tagging/help.php
new file mode 100644
index 000000000..a7f437e51
--- /dev/null
+++ b/views/default/photos/tagging/help.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Instructions on how to peform photo tagging
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$button = elgg_view('output/url', array(
+ 'text' => elgg_echo('quit'),
+ 'href' => '#',
+ 'id' => 'tidypics-tagging-quit',
+));
+
+$instructions = elgg_echo('tidypics:taginstruct', array($button));
+?>
+<div id="tidypics-tagging-help" class="elgg-module elgg-module-popup tidypics-tagging-help pam hidden">
+ <?php echo $instructions; ?>
+</div>
diff --git a/views/default/photos/tagging/select.php b/views/default/photos/tagging/select.php
new file mode 100644
index 000000000..8894af63a
--- /dev/null
+++ b/views/default/photos/tagging/select.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Tag select view
+ *
+ * @uses $vars['entity']
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$body = elgg_view_form('photos/image/tag', array(), $vars);
+
+echo elgg_view_module('popup', elgg_echo('tidypics:tagthisphoto'), $body, array(
+ 'class' => 'tidypics-tagging-select pam hidden',
+ 'id' => 'tidypics-tagging-select',
+));