From de68eb78e60cde716279283a65f3531ea57b30e4 Mon Sep 17 00:00:00 2001 From: hukoeth Date: Wed, 8 Sep 2010 00:40:14 +0800 Subject: [PATCH 1/6] Added user sidebar block, Replaced user dropdown field with ajax input field, added some error handling @todo: user sidebar block displays 30 users maximum and only users with annotations associated with them, add a search field allowing to search for all other users --- .../controllers/admin_photoannotation.php | 12 ++-- .../controllers/photoannotation.php | 38 +++++++++++ .../photoannotation/css/photoannotation.css | 68 +++++++++++++++++++ .../helpers/photoannotation.php | 34 ++++++++++ .../helpers/photoannotation_block.php | 38 +++++++++++ .../helpers/photoannotation_event.php | 2 +- .../helpers/photoannotation_theme.php | 2 +- modules/photoannotation/js/jquery.annotate.js | 39 +++++------ .../views/photoannotation_block.html.php | 26 +++++++ .../views/photoannotation_cloud.html.php | 9 +++ .../photoannotation_highlight_block.html.php | 21 ++---- 11 files changed, 245 insertions(+), 44 deletions(-) create mode 100644 modules/photoannotation/helpers/photoannotation_block.php create mode 100644 modules/photoannotation/views/photoannotation_block.html.php create mode 100644 modules/photoannotation/views/photoannotation_cloud.html.php diff --git a/modules/photoannotation/controllers/admin_photoannotation.php b/modules/photoannotation/controllers/admin_photoannotation.php index 535c004a..2ce1d7cf 100644 --- a/modules/photoannotation/controllers/admin_photoannotation.php +++ b/modules/photoannotation/controllers/admin_photoannotation.php @@ -90,17 +90,17 @@ class Admin_Photoannotation_Controller extends Admin_Controller { module::set_var( "photoannotation", "notificationoptout", $form->notifications->notificationoptout->value, true); module::set_var( - "photoannotation", "newtagsubject", $form->newtagmail->newtagsubject->value); + "photoannotation", "newtagsubject", strip_tags($form->newtagmail->newtagsubject->value)); module::set_var( - "photoannotation", "newtagbody", $form->newtagmail->newtagbody->value); + "photoannotation", "newtagbody", strip_tags($form->newtagmail->newtagbody->value)); module::set_var( - "photoannotation", "newcommentsubject", $form->newcommentmail->newcommentsubject->value); + "photoannotation", "newcommentsubject", strip_tags($form->newcommentmail->newcommentsubject->value)); module::set_var( - "photoannotation", "newcommentbody", $form->newcommentmail->newcommentbody->value); + "photoannotation", "newcommentbody", strip_tags($form->newcommentmail->newcommentbody->value)); module::set_var( - "photoannotation", "updatedcommentsubject", $form->updatedcommentmail->updatedcommentsubject->value); + "photoannotation", "updatedcommentsubject", strip_tags($form->updatedcommentmail->updatedcommentsubject->value)); module::set_var( - "photoannotation", "updatedcommentbody", $form->updatedcommentmail->updatedcommentbody->value); + "photoannotation", "updatedcommentbody", strip_tags($form->updatedcommentmail->updatedcommentbody->value)); module::set_var( "photoannotation", "onuserdelete", $form->onuserdelete->onuserdelete->value); message::success(t("Your settings have been saved.")); diff --git a/modules/photoannotation/controllers/photoannotation.php b/modules/photoannotation/controllers/photoannotation.php index 0ba8a79c..01528735 100644 --- a/modules/photoannotation/controllers/photoannotation.php +++ b/modules/photoannotation/controllers/photoannotation.php @@ -31,9 +31,29 @@ class photoannotation_Controller extends Controller { $str_x2 = $_POST["width"] + $str_x1; //Annotation uses area size, tagfaces uses positions $item_title = $_POST["text"]; $tag_data = $_POST["tagsList"]; + $user_id = ""; $user_id = $_POST["userlist"]; $description = $_POST["desc"]; $redir_uri = url::abs_site("{$item->type}s/{$item->id}"); + //If this is a user then get the id + if ($user_id != "") { + $user_parts = explode("(", $user_id); + $user_part = rtrim(ltrim(end($user_parts)), ")"); + $user = ORM::factory("user")->where("name", "=", $user_part)->find(); + $user_firstpart = trim(implode(array_slice($user_parts, 0, count($user_parts)-1))); + if (!$user->loaded() || strcasecmp($user_firstpart, $user->display_name()) <> 0) { + message::error(t("Could not find user %user.", array("user" => $user_id))); + url::redirect($redir_uri); + return; + } + if (strcasecmp($user->name, "guest") == 0) { + message::error(t("You cannot create an annotation for the guest user.")); + url::redirect($redir_uri); + return; + } + $user_id = $user->id; + } + //Add tag to item, create tag if not exists if ($tag_data != "") { $tag = ORM::factory("tag")->where("name", "=", $tag_data)->find(); @@ -161,4 +181,22 @@ class photoannotation_Controller extends Controller { message::success(t("Annotation deleted.")); url::redirect($redir_uri); } + + public function autocomplete() { + $users = array(); + $user_parts = explode(",", Input::instance()->get("q")); + $limit = Input::instance()->get("limit"); + $user_part = ltrim(end($user_parts)); + $user_list = ORM::factory("user") + ->where("name", "LIKE", "{$user_part}%") + ->order_by("name", "ASC") + ->limit($limit) + ->find_all(); + foreach ($user_list as $user) { + if ($user->name != "guest") { + $users[] = $user->display_name() ." (". $user->name .")"; + } + } + print implode("\n", $users); + } } diff --git a/modules/photoannotation/css/photoannotation.css b/modules/photoannotation/css/photoannotation.css index de3e6f87..deda3825 100644 --- a/modules/photoannotation/css/photoannotation.css +++ b/modules/photoannotation/css/photoannotation.css @@ -1,3 +1,71 @@ +/* Tag cloud ~~~~~~~~~~~~~~~~~~~~~~~ */ + +#g-user-cloud ul { + font-size: 1.2em; + text-align: justify; +} + +#g-user-cloud ul li { + display: inline; + line-height: 1.5em; + text-align: justify; +} + +#g-user-cloud ul li a { + text-decoration: none; +} + +#g-user-cloud ul li span { + display: none; +} + +#g-user-cloud ul li.size1 a { + color: #9cf; + font-size: 80%; + font-weight: 100; +} + +#g-user-cloud ul li.size2 a { + color: #69f; + font-size: 90%; + font-weight: 300; +} + +#g-user-cloud ul li.size3 a { + color: #69c; + font-size: 100%; + font-weight: 500; +} + +#g-user-cloud ul li.size4 a { + color: #369; + font-size: 110%; + font-weight: 700; +} + +#g-user-cloud ul li.size5 a { + color: #0e2b52; + font-size: 120%; + font-weight: 900; +} + +#g-user-cloud ul li.size6 a { + color: #0e2b52; + font-size: 130%; + font-weight: 900; +} + +#g-user-cloud ul li.size7 a { + color: #0e2b52; + font-size: 140%; + font-weight: 900; +} + +#g-user-cloud ul li a:hover { + color: #f30; + text-decoration: underline; +} + .image-annotate-canvas { background-position: left top; background-repeat: no-repeat; diff --git a/modules/photoannotation/helpers/photoannotation.php b/modules/photoannotation/helpers/photoannotation.php index 3e45265f..3af7333b 100644 --- a/modules/photoannotation/helpers/photoannotation.php +++ b/modules/photoannotation/helpers/photoannotation.php @@ -94,6 +94,10 @@ class photoannotation_Core { } //Only send mail if the notifications are switched on globally if (!module::get_var("photoannotation", "nonotifications", false)) { + //Check if the use has a valid e-mail + if (!valid::email($recipient->email)) { + return false; + } //Get the users settings $notification_settings = self::get_user_notification_settings($recipient); //Check which type of mail to send @@ -134,6 +138,7 @@ class photoannotation_Core { private static function _send_mail($mailto, $subject, $message) { //Send the notification mail + $message = nl2br($message); return Sendmail::factory() ->to($mailto) ->subject($subject) @@ -168,4 +173,33 @@ class photoannotation_Core { } return $user_array; } + + static function cloud($count) { + $users = ORM::factory("user")->order_by("name", "ASC")->find_all(); + if ($users) { + $cloud = new View("photoannotation_cloud.html"); + $fullname = module::get_var("photoannotation", "fullname", false); + foreach ($users as $user) { + $annotations = ORM::factory("items_user")->where("user_id", "=", $user->id)->count_all(); + if ($annotations > 0) { + if ($annotations > $maxcount) { + $maxcount = $annotations; + } + if ($fullname) { + $user_array[$user->name]->name = $user->display_name(); + } else { + $user_array[$user->name]->name = $user->name; + } + $user_array[$user->name]->size = $annotations; + $user_array[$user->name]->url = user_profile::url($user->id); + } + } + $cloud->users = array_slice($user_array, 0, $count); + $cloud->max_count = $maxcount; + if (!$cloud->max_count) { + return; + } + return $cloud; + } + } } \ No newline at end of file diff --git a/modules/photoannotation/helpers/photoannotation_block.php b/modules/photoannotation/helpers/photoannotation_block.php new file mode 100644 index 00000000..b92300cf --- /dev/null +++ b/modules/photoannotation/helpers/photoannotation_block.php @@ -0,0 +1,38 @@ + t("Users")); + } + + static function get($block_id, $theme) { + $block = ""; + switch ($block_id) { + case "photoannotation": + $block = new Block(); + $block->css_id = "g-photoannotation"; + $block->title = t("Users"); + $block->content = new View("photoannotation_block.html"); + $block->content->cloud = photoannotation::cloud(30); + $block->content->form = ""; + } + return $block; + } +} \ No newline at end of file diff --git a/modules/photoannotation/helpers/photoannotation_event.php b/modules/photoannotation/helpers/photoannotation_event.php index cf841ac3..2d58af53 100644 --- a/modules/photoannotation/helpers/photoannotation_event.php +++ b/modules/photoannotation/helpers/photoannotation_event.php @@ -233,7 +233,7 @@ class photoannotation_event_Core { $item_users = ORM::factory("items_user")->where("item_id", "=", $comment->item_id)->find_all(); if (count($item_users) > 0) { foreach ($item_users as $item_user) { - photoannotation::send_notifications($item_user->user_id, $comment->item_id, "updatecomment"); + photoannotation::send_notifications($item_user->user_id, $comment->item_id, "updatedcomment"); } } } diff --git a/modules/photoannotation/helpers/photoannotation_theme.php b/modules/photoannotation/helpers/photoannotation_theme.php index dcc5daa3..82997a9f 100644 --- a/modules/photoannotation/helpers/photoannotation_theme.php +++ b/modules/photoannotation/helpers/photoannotation_theme.php @@ -19,8 +19,8 @@ */ class photoannotation_theme_Core { static function head($theme) { + $theme->css("photoannotation.css"); if ($theme->page_subtype == "photo") { - $theme->css("photoannotation.css"); $theme->script("jquery.annotate.js"); $noborder = module::get_var("photoannotation", "noborder", false); $noclickablehover = module::get_var("photoannotation", "noclickablehover", false); diff --git a/modules/photoannotation/js/jquery.annotate.js b/modules/photoannotation/js/jquery.annotate.js index ba98339e..0fe204f9 100644 --- a/modules/photoannotation/js/jquery.annotate.js +++ b/modules/photoannotation/js/jquery.annotate.js @@ -214,6 +214,7 @@ newNote.text = ""; newNote.description = ""; newNote.notetype = ""; + newNote.internaltext = ""; this.note = newNote; } @@ -236,31 +237,19 @@ var selecteduser = ""; if (this.note.notetype == "face") { selectedtag = this.note.text; - selecteduser = " selected=\"selected\""; } else if (this.note.notetype == "user") { - username = this.note.text; + username = this.note.internaltext; } else { notetitle = this.note.text; - selecteduser = " selected=\"selected\""; } - var userdropdown = ''; var form = $('
\
\ \ \
' + labels[12] + '\ - ' + userdropdown + - '
' + labels[4] + '
\ + \ + \ +
' + labels[4] + '
\ \ ' + '
' + labels[4] + '
\ @@ -282,13 +271,23 @@ cacheLength: 1 } ); + var urlusers = users; + $("input#photoannotation-user-list").autocomplete( + urlusers, { + max: 30, + multiple: false, + cacheLength: 1 + } + ); }); - $("input#image-annotate-tag-text").change(function() { + $("input#image-annotate-tag-text").keyup(function() { if ($("input#image-annotate-tag-text").val() != "") { $("input#image-annotate-text").html(""); $("input#image-annotate-text").val(""); $("input#image-annotate-text").text(""); - $("select#photoannotation-user-list").val('-1'); + $("input#photoannotation-user-list").html(""); + $("input#photoannotation-user-list").val(""); + $("input#photoannotation-user-list").text(""); } }); $("input#image-annotate-text").keyup(function() { @@ -296,7 +295,9 @@ $("input#image-annotate-tag-text").html(""); $("input#image-annotate-tag-text").val(""); $("input#image-annotate-tag-text").text(""); - $("select#photoannotation-user-list").val('-1'); + $("input#photoannotation-user-list").html(""); + $("input#photoannotation-user-list").val(""); + $("input#photoannotation-user-list").text(""); } }); $("select#photoannotation-user-list").keyup(function() { diff --git a/modules/photoannotation/views/photoannotation_block.html.php b/modules/photoannotation/views/photoannotation_block.html.php new file mode 100644 index 00000000..4ce270db --- /dev/null +++ b/modules/photoannotation/views/photoannotation_block.html.php @@ -0,0 +1,26 @@ + + +
"> + +
+ \ No newline at end of file diff --git a/modules/photoannotation/views/photoannotation_cloud.html.php b/modules/photoannotation/views/photoannotation_cloud.html.php new file mode 100644 index 00000000..6f47b272 --- /dev/null +++ b/modules/photoannotation/views/photoannotation_cloud.html.php @@ -0,0 +1,9 @@ + +
    + +
  • + size ?> photos are tagged with + name) ?> +
  • + +
diff --git a/modules/photoannotation/views/photoannotation_highlight_block.html.php b/modules/photoannotation/views/photoannotation_highlight_block.html.php index 1e61bda6..6e7b48e9 100644 --- a/modules/photoannotation/views/photoannotation_highlight_block.html.php +++ b/modules/photoannotation/views/photoannotation_highlight_block.html.php @@ -9,7 +9,6 @@ $existingNotes = ORM::factory("items_note") ->where("item_id", "=", $item->id) ->find_all(); - $users = ORM::factory("user")->order_by("name", "ASC")->find_all(); $fullname = module::get_var("photoannotation", "fullname", false); $showusers = module::get_var("photoannotation", "showusers", false); $showfaces = module::get_var("photoannotation", "showfaces", false); @@ -37,8 +36,8 @@ foreach ($existingUsers as $oneUser) { $oneTag = ORM::factory("user", $oneUser->user_id); if ($oneTag->loaded()) { - if ($fullname && ($oneTag->full_name != "")) { - $user_text = $oneTag->full_name; + if ($fullname) { + $user_text = $oneTag->display_name(); } else { $user_text = $oneTag->name; } @@ -50,6 +49,7 @@ $jscode .= "\"width\": ". ($oneUser->x2 - $oneUser->x1) .",\n"; $jscode .= "\"height\": ". ($oneUser->y2 - $oneUser->y1) .",\n"; $jscode .= "\"text\": \"". html::clean($user_text) ."\",\n"; + $jscode .= "\"internaltext\": \"". $oneTag->display_name() ." (". $oneTag->name .")\",\n"; $jscode .= "\"description\": \"". html::clean($oneUser->description) ."\",\n"; $jscode .= "\"noteid\": ". $oneUser->id .",\n"; $jscode .= "\"notetype\": \"user\",\n"; @@ -110,19 +110,6 @@ $legend_display = $legend_users . "
" . $legend_faces . "
" . $legend_notes; $legend_display = str_replace("

", "
", $legend_display); } - $users_arraystring = "users: [ "; - foreach ($users as $user) { - if ($fullname && ($user->full_name != "")) { - $user_text = $user->full_name; - } else { - $user_text = $user->name; - } - if ($user->name != "guest") { - $users_arraystring .= "{'name':'". html::clean($user_text) ."','id':'". $user->id ."'},"; - } - } - $users_arraystring = trim($users_arraystring, ","); - $users_arraystring .= " ],"; $labels_arraystring = "labels: [ '". t("Tag:") ."','". t("Note Title:") ."','". t("Description (optional)") ."','". t("Are you sure you want to delete this annotation?") ."','". t("or") ."','". t("Yes") ."','". t("No") ."','". t("Confirm deletion") ."','". t("Save") ."','". t("Cancel") ."','". t("User:") ."','". t("No user selected") ."','". t("Select one of the following") ."' ],"; ?>
"> diff --git a/modules/photoannotation/views/photoannotation_user_search.html.php b/modules/photoannotation/views/photoannotation_user_search.html.php new file mode 100644 index 00000000..42f32519 --- /dev/null +++ b/modules/photoannotation/views/photoannotation_user_search.html.php @@ -0,0 +1,55 @@ + + +
"> +

+ + + + + id) ."\">" ?> +
+

" + alt="display_name()) ?>" + class="g-avatar" width="40" height="40" /> + name ?>

+
+ + + + + + + + + + + + + + + + +
display_name() ?>
id) ?>
id) ?>
+
+
+ + + + + +
\ No newline at end of file From daf1d8a66c68e88f0e145869f4dc600cdd95da43 Mon Sep 17 00:00:00 2001 From: hukoeth Date: Thu, 9 Sep 2010 22:14:18 +0800 Subject: [PATCH 4/6] Fixed typo in admin area Added option to hide the user cloud for guests Don't send notification mail on new comment when notification module is active and user is watching item --- .../controllers/admin_photoannotation.php | 10 +++++++--- .../controllers/photoannotation.php | 11 ++++++++--- .../helpers/photoannotation.php | 12 ++++++++++++ .../helpers/photoannotation_block.php | 18 ++++++++++-------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/photoannotation/controllers/admin_photoannotation.php b/modules/photoannotation/controllers/admin_photoannotation.php index 2ce1d7cf..2aaf5838 100644 --- a/modules/photoannotation/controllers/admin_photoannotation.php +++ b/modules/photoannotation/controllers/admin_photoannotation.php @@ -89,6 +89,8 @@ class Admin_Photoannotation_Controller extends Admin_Controller { "photoannotation", "nonotifications", $form->notifications->nonotifications->value, true); module::set_var( "photoannotation", "notificationoptout", $form->notifications->notificationoptout->value, true); + module::set_var( + "photoannotation", "allowguestsearch", $form->notifications->allowguestsearch->value, true); module::set_var( "photoannotation", "newtagsubject", strip_tags($form->newtagmail->newtagsubject->value)); module::set_var( @@ -251,19 +253,21 @@ class Admin_Photoannotation_Controller extends Admin_Controller { ->value(module::get_var("photoannotation", "hovercolor", "990000")) ->rules("valid_alpha_numeric|length[6]"); $group = $form->group("legendsettings")->label(t("Legend settings")); - $group->checkbox("showusers")->label(t("Show face annotation below photo.")) + $group->checkbox("showusers")->label(t("Show user annotations below photo.")) ->checked(module::get_var("photoannotation", "showusers", false)); - $group->checkbox("showfaces")->label(t("Show face annotation below photo.")) + $group->checkbox("showfaces")->label(t("Show tag annotations below photo.")) ->checked(module::get_var("photoannotation", "showfaces", false)); $group->checkbox("shownotes")->label(t("Show note annotations below photo.")) ->checked(module::get_var("photoannotation", "shownotes", false)); $group->checkbox("fullname")->label(t("Show full name of a user instead of the username on annotations (username will be dispayed for users without a full name).")) ->checked(module::get_var("photoannotation", "fullname", false)); - $group = $form->group("notifications")->label(t("Notification settings")); + $group = $form->group("notifications")->label(t("Notification and user cloud settings")); $group->checkbox("nonotifications")->label(t("Disable user notifications.")) ->checked(module::get_var("photoannotation", "nonotifications", false)); $group->checkbox("notificationoptout")->label(t("Notify users by default (only applies to new users and user who have not saved their profile after installing this module).")) ->checked(module::get_var("photoannotation", "notificationoptout", false)); + $group->checkbox("allowguestsearch")->label(t("Show user cloud and allow user search for guests.")) + ->checked(module::get_var("photoannotation", "allowguestsearch", false)); $group = $form->group("newtagmail")->label(t("Customize the mail sent to users when a user annotation is created")); $group->input("newtagsubject")->label(t("Subject")) ->value(module::get_var("photoannotation", "newtagsubject", "Someone tagged a photo of you")); diff --git a/modules/photoannotation/controllers/photoannotation.php b/modules/photoannotation/controllers/photoannotation.php index c83cbee9..1431a311 100644 --- a/modules/photoannotation/controllers/photoannotation.php +++ b/modules/photoannotation/controllers/photoannotation.php @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class photoannotation_Controller extends Controller { - public function showuser($item_id) { + public function showuser() { + if (identity::active_user()->guest && !module::get_var("photoannotation", "allowguestsearch", false)) { + message::error(t("You have to log in to perform a user search.")); + url::redirect(url::site()); + return; + } $form = photoannotation::get_user_search_form("g-user-cloud-form"); $user_id = Input::instance()->get("name", ""); if ($user_id == "") { @@ -40,10 +45,10 @@ class photoannotation_Controller extends Controller { list ($count, $result) = photoannotation::search_user($user_id, $page_size, $offset); $max_pages = max(ceil($count / $page_size), 1); if ($page > 1) { - $previous_page_url = url::site("photoannotation/showuser/". $item_id ."?name=". $user_id ."&page=". ($page - 1)); + $previous_page_url = url::site("photoannotation/showuser?name=". $user_id ."&page=". ($page - 1)); } if ($page < $max_pages) { - $next_page_url = url::site("photoannotation/showuser/". $item_id ."?name=". $user_id ."&page=". ($page + 1)); + $next_page_url = url::site("photoannotation/showuser?name=". $user_id ."&page=". ($page + 1)); } if ($user_id == "") { $user_id = "*"; diff --git a/modules/photoannotation/helpers/photoannotation.php b/modules/photoannotation/helpers/photoannotation.php index cd58f554..13ec4078 100644 --- a/modules/photoannotation/helpers/photoannotation.php +++ b/modules/photoannotation/helpers/photoannotation.php @@ -171,6 +171,12 @@ class photoannotation_Core { case "newcomment": //Only send if user has this option enabled if ($notification_settings->comment) { + //Don't send if the notification module is active and the user is watching this item + if (module::is_active("notification")) { + if (notification::is_watching($item, $recipient)) { + return false; + } + } //Get subject and body and send the mail $subject = module::get_var("photoannotation", "newcommentsubject", "Someone added a comment to photo of you"); $body = module::get_var("photoannotation", "newcommentbody", "Hello %name, please visit %url to read the comment."); @@ -181,6 +187,12 @@ class photoannotation_Core { case "updatecomment": //Only send if user has this option enabled if ($notification_settings->comment) { + //Don't send if the notification module is active and the user is watching this item + if (module::is_active("notification")) { + if (notification::is_watching($item, $recipient)) { + return false; + } + } //Get subject and body and send the mail $subject = module::get_var("photoannotation", "updatedcommentsubject", "Someone updated a comment to photo of you"); $body = module::get_var("photoannotation", "updatedcommentbody", "Hello %name, please visit %url to read the comment."); diff --git a/modules/photoannotation/helpers/photoannotation_block.php b/modules/photoannotation/helpers/photoannotation_block.php index 250d1eaa..6facc671 100644 --- a/modules/photoannotation/helpers/photoannotation_block.php +++ b/modules/photoannotation/helpers/photoannotation_block.php @@ -24,15 +24,17 @@ class photoannotation_block_Core { static function get($block_id, $theme) { $block = ""; - switch ($block_id) { - case "photoannotation": - $block = new Block(); - $block->css_id = "g-photoannotation"; - $block->title = t("Users"); - $block->content = new View("photoannotation_block.html"); - $block->content->cloud = photoannotation::cloud(30); - $block->content->form = photoannotation::get_user_search_form("g-user-cloud-form"); + if (!identity::active_user()->guest || module::get_var("photoannotation", "allowguestsearch", false)) { + switch ($block_id) { + case "photoannotation": + $block = new Block(); + $block->css_id = "g-photoannotation"; + $block->title = t("Users"); + $block->content = new View("photoannotation_block.html"); + $block->content->cloud = photoannotation::cloud(30); + $block->content->form = photoannotation::get_user_search_form("g-user-cloud-form"); } + } return $block; } } \ No newline at end of file From 4fe8e218360a5338b8d014a6d04e88b29ee7f206 Mon Sep 17 00:00:00 2001 From: hukoeth Date: Sat, 11 Sep 2010 17:29:24 +0800 Subject: [PATCH 5/6] Disable notification when converting tag to user annotations, added option to converter to allow deletion and/or removal of tag after conversion --- .../controllers/admin_photoannotation.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) mode change 100644 => 100755 modules/photoannotation/controllers/admin_photoannotation.php diff --git a/modules/photoannotation/controllers/admin_photoannotation.php b/modules/photoannotation/controllers/admin_photoannotation.php old mode 100644 new mode 100755 index 2aaf5838..bdcd71be --- a/modules/photoannotation/controllers/admin_photoannotation.php +++ b/modules/photoannotation/controllers/admin_photoannotation.php @@ -48,17 +48,34 @@ class Admin_Photoannotation_Controller extends Admin_Controller { } //Load all existing tag annotations $tag_annotations = ORM::factory("items_face")->where("tag_id", "=", $sourcetag->id)->find_all(); - + //Disable user notifications so that users don't get flooded with mails + $old_notification_setting = module::get_var("photoannotation", "nonotifications", false); + module::set_var("photoannotation", "nonotifications", true, true); foreach ($tag_annotations as $tag_annotation) { photoannotation::saveuser($targetuser->id, $tag_annotation->item_id, $tag_annotation->x1, $tag_annotation->y1, $tag_annotation->x2, $tag_annotation->y2, $tag_annotation->description); //Delete the old annotation $tag_annotation->delete(); } + //Remove and delete old tag + if ($form->deletetag->value) { + $this->_remove_tag($sourcetag, true); + } elseif ($form->removetag->value) { + $this->_remove_tag($sourcetag, false); + } + module::set_var("photoannotation", "nonotifications", $old_notification_setting, true); message::success(t("%count tag annotations (%tagname) have been converted to user annotations (%username)", array("count" => count($tag_annotations), "tagname" => $sourcetag->name, "username" => $targetuser->display_name()))); url::redirect("admin/photoannotation/converter"); } print $this->_get_converter_view($form); } + + private function _remove_tag($tag, $delete) { + $name = $tag->name; + db::build()->delete("items_tags")->where("tag_id", "=", $tag->id)->execute(); + if ($delete) { + $tag->delete(); + } + } public function handler() { access::verify_csrf(); @@ -223,6 +240,8 @@ class Admin_Photoannotation_Controller extends Admin_Controller { ->options($tag_array); $form->dropdown("targetuser")->label(t("Select user")) ->options($user_array); + $form->checkbox("deletetag")->label(t("Delete the tag after conversion.")); + $form->checkbox("removetag")->label(t("Remove the tag from photos after conversion.")); $form->submit("submit")->value(t("Convert")); return $form; } From 6e5e05755c106d436db809bd0f5850a659acdbac Mon Sep 17 00:00:00 2001 From: root Date: Sat, 11 Sep 2010 17:24:52 +0800 Subject: [PATCH 6/6] Add keyboard navigation module from http://photo.dragonsoft.us/clickcount/click.php?id=9 --- modules/kbd_nav/changelog.txt | 20 +++++ modules/kbd_nav/helpers/kbd_nav_theme.php | 8 ++ modules/kbd_nav/js/kbd_nav.js | 97 +++++++++++++++++++++++ modules/kbd_nav/module.info | 3 + 4 files changed, 128 insertions(+) create mode 100644 modules/kbd_nav/changelog.txt create mode 100644 modules/kbd_nav/helpers/kbd_nav_theme.php create mode 100644 modules/kbd_nav/js/kbd_nav.js create mode 100644 modules/kbd_nav/module.info diff --git a/modules/kbd_nav/changelog.txt b/modules/kbd_nav/changelog.txt new file mode 100644 index 00000000..203fdea1 --- /dev/null +++ b/modules/kbd_nav/changelog.txt @@ -0,0 +1,20 @@ +Kbd Navigation Changelog + +version 1.5: +- Fix for RTL detection +- Added support for Wind theme + +version 1.4: +- Added RTL detection + +version 1.3: +- Internal revision + +version 1.2: +- Added support for GreyDragon Photo Slideshow navigation - in Photo SB slideshow mode, key navigation is superseded by slideshow navigation. + +version 1.1: +- Internal revision + +version 1.0: +- Initial release \ No newline at end of file diff --git a/modules/kbd_nav/helpers/kbd_nav_theme.php b/modules/kbd_nav/helpers/kbd_nav_theme.php new file mode 100644 index 00000000..6540f020 --- /dev/null +++ b/modules/kbd_nav/helpers/kbd_nav_theme.php @@ -0,0 +1,8 @@ +script("kbd_nav.js"); + } +} \ No newline at end of file diff --git a/modules/kbd_nav/js/kbd_nav.js b/modules/kbd_nav/js/kbd_nav.js new file mode 100644 index 00000000..83c95969 --- /dev/null +++ b/modules/kbd_nav/js/kbd_nav.js @@ -0,0 +1,97 @@ +/** +* +* Copyright (c) 2010 Serguei Dosyukov, http://blog.dragonsoft.us +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, +* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +$.fn.KbdNavigation = function(options, callback) { + + this.options = options || {}; + var opt = this.options; + this.callback = callback || null; + var clbk = this.callback; + + $(this).bind("keydown", function(event) { + if ($('#sb-body-inner>img#sb-content').is(':visible')) { + return false; + } + + var direction = "ltr"; + if (document.body) { + if (window.getComputedStyle) { + direction = window.getComputedStyle(document.body, null).direction; + } else if (document.body.currentStyle) { + direction = document.body.currentStyle.direction; + } + } + + var lnk = ""; + var lnk_first, lnk_prev, lnk_parent, lnk_next, lnk_last; + + if(opt.first) { lnk_first = opt.first; } else { lnk_first = $("#g-navi-first").attr("href"); } + if(opt.prev) { lnk_prev = opt.prev; } else { lnk_prev = $("#g-navi-prev").attr("href"); } + if(opt.parent) { lnk_parent = opt.parent; } else { lnk_parent = $("#g-navi-parent").attr("href"); } + if(opt.next) { lnk_next = opt.next; } else { lnk_next = $("#g-navi-next").attr("href"); } + if(opt.last) { lnk_last = opt.last; } else { lnk_last = $("#g-navi-last").attr("href"); } + + // Support for standard Wind Theme tags + if(!lnk_first) { lnk_first = $(".g-paginator .ui-icon-seek-first").parent().attr("href"); } + if(!lnk_prev) { lnk_prev = $(".g-paginator .ui-icon-seek-prev").parent().attr("href"); } + if(!lnk_next) { lnk_next = $(".g-paginator .ui-icon-seek-next").parent().attr("href"); } + if(!lnk_last) { lnk_last = $(".g-paginator .ui-icon-seek-end").parent().attr("href"); } + + var keyCode = event.keyCode; + + if (direction == "rtl") { + switch(keyCode) { + case 0x25: // Left + keyCode = 0x27; + break; + case 0x27: // Right + keyCode = 0x25; + break; + } + } + + switch(keyCode) { + case 0x25: // Ctr+Left/Left + if(event.ctrlKey) { lnk = lnk_first; } else { lnk = lnk_prev; } + break; + case 0x26: // Ctrl+Up + if(event.ctrlKey) { lnk = lnk_parent; } + break; + case 0x27: // Ctrl+Right/Right + if(event.ctrlKey) { lnk = lnk_last; } else { lnk = lnk_next; } + break; + } + + if(lnk) { + if(typeof clbk == 'function') { + clbk(); + return false; + } else { + window.location = lnk; + return true; + } + } + + return true; + }); +} + +$(document).ready( function() { + $(document).KbdNavigation({}); + if ($('#sb-content').is(':visible')) { return true; } +}); \ No newline at end of file diff --git a/modules/kbd_nav/module.info b/modules/kbd_nav/module.info new file mode 100644 index 00000000..2eda7c73 --- /dev/null +++ b/modules/kbd_nav/module.info @@ -0,0 +1,3 @@ +name = "Kbd Navigation" +description = "Adds keyboard navigation to the gallery.
Version 1.5 | By Serguei Dosyukov | Visit plugin Site | Support" +version = 5