]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added photo tagging - but not displaying or deleting tags yet
authorcash <cash.costello@gmail.com>
Mon, 2 Jan 2012 17:45:16 +0000 (12:45 -0500)
committercash <cash.costello@gmail.com>
Mon, 2 Jan 2012 17:45:16 +0000 (12:45 -0500)
actions/photos/image/tag.php [moved from actions/addtag.php with 70% similarity]
languages/en.php
pages/photos/image/view.php
start.php
views/default/forms/photos/image/tag.php [new file with mode: 0644]
views/default/js/photos/tagging.php [new file with mode: 0644]
views/default/object/image/full.php
views/default/photos/css.php
views/default/photos/tagging/help.php [new file with mode: 0644]
views/default/photos/tagging/select.php [new file with mode: 0644]

similarity index 70%
rename from actions/addtag.php
rename to actions/photos/image/tag.php
index 97418f495c18091777b361ee7cb410ff0eca528a..0c7ce06aedc6aa2b9ae875da02f476bf96aa4a3a 100644 (file)
@@ -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);
index ec65d0622360a0e66bcc0c1f0a8879e09d48e233..2276e4b12da0017871ee7c201a1b940d38ceda27 100644 (file)
@@ -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',
index f9157a900b56fdf9846878fb6c3f08a87292872d..6db9ff529839e209b2f1d4ac54e10a80455e62ad 100644 (file)
@@ -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) {
index 5638037ccc5e825cc11208d20d4a33654268758a..a81c1d8544d0f90e34cd52bb0e63dd2dfc89ef7d 100644 (file)
--- 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 (file)
index 0000000..31869be
--- /dev/null
@@ -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 (file)
index 0000000..f831200
--- /dev/null
@@ -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);
index e3a2c700395b0448c1e0c1b7f386da96b4586775..33ba497393f3155d02f1145a44626e295eb31e06 100644 (file)
@@ -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>';
 
index 18f225131995123e58d2b4179f1c7a5c0c02b5f4..31e3d9b537c027d5383551658ea3e80cecb1415c 100644 (file)
@@ -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;
        display: block;
 }
 
+.tidypics-wrapper-photo {
+       position: relative;
+}
+
 .tidypics-heading {
        color: #0054A7;
 }
        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 (file)
index 0000000..a7f437e
--- /dev/null
@@ -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 (file)
index 0000000..8894af6
--- /dev/null
@@ -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',
+));