From fcc446bf006f88d2079f52ed559c31f01c156dbe Mon Sep 17 00:00:00 2001 From: ckieffer Date: Sat, 8 May 2010 13:54:27 -0600 Subject: Move print with digibug to the site menu. --- modules/digibug/helpers/digibug_event.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/digibug/helpers/digibug_event.php b/modules/digibug/helpers/digibug_event.php index cf7cdf21..4c842615 100644 --- a/modules/digibug/helpers/digibug_event.php +++ b/modules/digibug/helpers/digibug_event.php @@ -26,14 +26,17 @@ class digibug_event_Core { ->url(url::site("admin/digibug"))); } - static function photo_menu($menu, $theme) { + static function site_menu($menu, $theme) { $item = $theme->item(); - $menu->append(Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_id("g-print-digibug-link") - ->css_class("g-print-digibug-link ui-icon-print")); + if ($item->type == "photo") { + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) + ->css_id("g-print-digibug-link") + ->css_class("g-print-digibug-link ui-icon-print")); + } } static function context_menu($menu, $theme, $item) { -- cgit v1.2.3 From 44753c524996415f465f44d05be46e878911ce4a Mon Sep 17 00:00:00 2001 From: ckieffer Date: Sat, 8 May 2010 15:05:56 -0600 Subject: Deleted extra CSS class assignment for context_menu delete option. --- modules/gallery/helpers/gallery_event.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index d723cc1b..c77ed9d4 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -383,7 +383,6 @@ class gallery_event_Core { ->id("delete") ->label($delete_title) ->css_class("ui-icon-trash") - ->css_class("g-quick-delete") ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); } -- cgit v1.2.3 From d98b85f7d3142676e6b4f407a18ed81564823f88 Mon Sep 17 00:00:00 2001 From: ckieffer Date: Fri, 14 May 2010 17:14:34 -0600 Subject: Drop context_menu for wind's photo/resize view. Move photo edit options to the site_menu. --- modules/gallery/helpers/gallery_event.php | 54 +++++++++++++++++++++++++++++++ themes/wind/views/photo.html.php | 1 - 2 files changed, 54 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index c77ed9d4..d01b2956 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -227,6 +227,60 @@ class gallery_event_Core { } } } + + if ($item->is_photo() && graphics::can("rotate")) { + $options_menu + ->append( + Menu::factory("ajax_link") + ->id("rotate_ccw") + ->label(t("Rotate 90° counter clockwise")) + ->css_class("ui-icon-rotate-ccw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))) + ->append( + Menu::factory("ajax_link") + ->id("rotate_cw") + ->label(t("Rotate 90° clockwise")) + ->css_class("ui-icon-rotate-cw") + ->ajax_handler("function(data) { " . + "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); + } + + if ($item->id != item::root()->id) { + $parent = $item->parent(); + if (access::can("edit", $parent)) { + // We can't make this item the highlight if it's an album with no album cover, or if it's + // already the album cover. + if (($item->type == "album" && empty($item->album_cover_item_id)) || + ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) || + $parent->album_cover_item_id == $item->id) { + $disabledState = " ui-state-disabled"; + } else { + $disabledState = " "; + } + + if ($item->parent()->id != 1) { + $options_menu + ->append( + Menu::factory("ajax_link") + ->id("make_album_cover") + ->label(t("Choose as the album cover")) + ->css_class("ui-icon-star") + ->ajax_handler("function(data) { window.location.reload() }") + ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf"))); + } + $options_menu + ->append( + Menu::factory("dialog") + ->id("delete") + ->label(t("Delete this photo")) + ->css_class("ui-icon-trash") + ->css_class("g-quick-delete") + ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); + } + } } if (identity::active_user()->admin) { diff --git a/themes/wind/views/photo.html.php b/themes/wind/views/photo.html.php index e0fae3f1..07952c94 100644 --- a/themes/wind/views/photo.html.php +++ b/themes/wind/views/photo.html.php @@ -27,7 +27,6 @@ resize_bottom($item) ?> - context_menu($item, "#g-photo-id-{$item->id}") ?>
-- cgit v1.2.3 From ad0e7254eb6e6a763c9b4d0a7252dc5982a814be Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 14 May 2010 16:19:53 -0700 Subject: Require a well-formed email address for all comments. --- modules/comment/controllers/comments.php | 3 ++- modules/comment/helpers/comment.php | 10 +++++++-- modules/comment/models/comment.php | 15 +++++++++++++- modules/comment/tests/Comment_Event_Test.php | 1 + modules/comment/tests/Comment_Model_Test.php | 31 ++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 9e0f86d2..465b1bcd 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -58,6 +58,7 @@ class Comments_Controller extends Controller { "view" => (string) $view, "form" => (string) comment::get_add_form($item))); } else { + $form = comment::prefill_add_form($form); print json_encode(array("result" => "error", "form" => (string) $form)); } } @@ -69,6 +70,6 @@ class Comments_Controller extends Controller { $item = ORM::factory("item", $item_id); access::required("view", $item); - print comment::get_add_form($item); + print comment::prefill_add_form(comment::get_add_form($item)); } } diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index e3486e83..94b14d0d 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -33,7 +33,9 @@ class comment_Core { ->error_messages("required", t("You must enter a name for yourself")); $group->input("email") ->label(t("Email (hidden)")) - ->id("g-email"); + ->id("g-email") + ->error_messages("required", t("You must enter a valid email address")) + ->error_messages("invalid", t("You must enter a valid email address")); $group->input("url") ->label(t("Website (hidden)")) ->id("g-url"); @@ -45,13 +47,17 @@ class comment_Core { module::event("comment_add_form", $form); $group->submit("")->value(t("Add"))->class("ui-state-default ui-corner-all"); + return $form; + } + + static function prefill_add_form($form) { $active = identity::active_user(); if (!$active->guest) { + $group = $form->add_comment; $group->inputs["name"]->value($active->full_name)->disabled("disabled"); $group->email->value($active->email)->disabled("disabled"); $group->url->value($active->url)->disabled("disabled"); } - return $form; } } diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index 48084340..fb70c79a 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -61,7 +61,7 @@ class Comment_Model extends ORM { if (!$array) { $this->rules = array( "guest_name" => array("callbacks" => array(array($this, "valid_author"))), - "guest_email" => array("rules" => array("email")), + "guest_email" => array("callbacks" => array(array($this, "valid_email"))), "guest_url" => array("rules" => array("url")), "item_id" => array("callbacks" => array(array($this, "valid_item"))), "state" => array("rules" => array("Comment_Model::valid_state")), @@ -144,6 +144,19 @@ class Comment_Model extends ORM { } } + /** + * Make sure that the email address is legal. + */ + public function valid_email(Validation $v, $field) { + if ($this->author_id == identity::guest()->id) { + if (empty($v->guest_email)) { + $v->add_error("guest_email", "required"); + } else if (!valid::email($v->guest_email)) { + $v->add_error("guest_email", "invalid"); + } + } + } + /** * Make sure we have a valid associated item id. */ diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php index 62ffec2f..7cae9297 100644 --- a/modules/comment/tests/Comment_Event_Test.php +++ b/modules/comment/tests/Comment_Event_Test.php @@ -25,6 +25,7 @@ class Comment_Event_Test extends Gallery_Unit_Test_Case { $comment->item_id = $album->id; $comment->author_id = identity::guest()->id; $comment->guest_name = "test"; + $comment->guest_email = "test@test.com"; $comment->text = "text"; $comment->save(); diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php index f4e944f0..ee4d3d3c 100644 --- a/modules/comment/tests/Comment_Model_Test.php +++ b/modules/comment/tests/Comment_Model_Test.php @@ -22,6 +22,37 @@ class Comment_Model_Test extends Gallery_Unit_Test_Case { identity::set_active_user(identity::admin_user()); } + public function guest_name_and_email_is_required_test() { + try { + $comment = ORM::factory("comment"); + $comment->item_id = item::root()->id; + $comment->author_id = identity::guest()->id; + $comment->text = "text"; + $comment->save(); + } catch (ORM_Validation_Exception $e) { + $this->assert_equal(array("guest_name" => "required", + "guest_email" => "required"), + $e->validation->errors()); + return; + } + } + + public function guest_email_must_be_well_formed_test() { + try { + $comment = ORM::factory("comment"); + $comment->item_id = item::root()->id; + $comment->author_id = identity::guest()->id; + $comment->guest_name = "guest"; + $comment->guest_email = "bogus"; + $comment->text = "text"; + $comment->save(); + } catch (ORM_Validation_Exception $e) { + $this->assert_equal(array("guest_email" => "invalid"), + $e->validation->errors()); + return; + } + } + public function cant_view_comments_for_unviewable_items_test() { $album = test::random_album(); -- cgit v1.2.3 From 3422185938436b44ee48515cd3cfa3df55bca3c8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 14 May 2010 16:51:51 -0700 Subject: Remove "rnd=" param from quick changes since we have the m= cache-buster already. --- modules/gallery/controllers/quick.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 813d1a93..6cfbbc62 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -58,12 +58,12 @@ class Quick_Controller extends Controller { if (Input::instance()->get("page_type") == "collection") { print json_encode( - array("src" => $item->thumb_url() . "?rnd=" . rand(), + array("src" => $item->thumb_url(), "width" => $item->thumb_width, "height" => $item->thumb_height)); } else { print json_encode( - array("src" => $item->resize_url() . "?rnd=" . rand(), + array("src" => $item->resize_url(), "width" => $item->resize_width, "height" => $item->resize_height)); } -- cgit v1.2.3 From 1240878df0f4a2b0ad0cdb32814717038ff2773f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 14 May 2010 16:55:15 -0700 Subject: Fix-ups for d98b85f7d3142676e6b4f407a18ed81564823f88 - Pass the CSS selector of the active image in as an arg to site_menu so that quick operations know what they're operating on. - Change the ids from g-{photo,movie}-id to the generic g-item-id - Initialize ajax handlers for site menu on the photo and movie page - Drop the movie context menu, it's now in the site menu --- modules/gallery/helpers/gallery_event.php | 9 ++++++--- modules/gallery/libraries/Theme_View.php | 4 ++-- modules/gallery/models/item.php | 2 +- themes/wind/js/ui.init.js | 3 +++ themes/wind/views/movie.html.php | 3 +-- themes/wind/views/page.html.php | 2 +- themes/wind/views/photo.html.php | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 9b3aa82d..89ad6a4c 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -167,7 +167,7 @@ class gallery_event_Core { } } - static function site_menu($menu, $theme) { + static function site_menu($menu, $theme, $item_css_selector) { if ($theme->page_subtype != "login") { $menu->append(Menu::factory("link") ->id("home") @@ -239,6 +239,9 @@ class gallery_event_Core { } } + $csrf = access::csrf_token(); + $theme_item = $theme->item(); + $page_type = $theme->page_type(); if ($item->is_photo() && graphics::can("rotate")) { $options_menu ->append( @@ -247,7 +250,7 @@ class gallery_event_Core { ->label(t("Rotate 90° counter clockwise")) ->css_class("ui-icon-rotate-ccw") ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + "\$.gallery_replace_image(data, \$('$item_css_selector')) }") ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))) ->append( Menu::factory("ajax_link") @@ -255,7 +258,7 @@ class gallery_event_Core { ->label(t("Rotate 90° clockwise")) ->css_class("ui-icon-rotate-cw") ->ajax_handler("function(data) { " . - "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }") + "\$.gallery_replace_image(data, \$('$item_css_selector')) }") ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 8b432fb6..6246c6f1 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -86,9 +86,9 @@ class Theme_View_Core extends Gallery_View { return $menu->render(); } - public function site_menu() { + public function site_menu($item_css_selector) { $menu = Menu::factory("root"); - module::event("site_menu", $menu, $this); + module::event("site_menu", $menu, $this, $item_css_selector); return $menu->render(); } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7fc37325..409ed3cc 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -674,7 +674,7 @@ class Item_Model extends ORM_MPTT { $v->attrs = array_merge($extra_attrs, array("style" => "display:block;width:{$this->width}px;height:{$this->height}px")); if (empty($v->attrs["id"])) { - $v->attrs["id"] = "g-movie-id-{$this->id}"; + $v->attrs["id"] = "g-item-id-{$this->id}"; } return $v; } diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js index 6edf6be4..53b58516 100644 --- a/themes/wind/js/ui.init.js +++ b/themes/wind/js/ui.init.js @@ -108,6 +108,9 @@ $(document).ready(function() { duration: 1000, hash: true }); + + $(this).find(".g-dialog-link").gallery_dialog(); + $(this).find(".g-ajax-link").gallery_ajax(); } // Initialize button hover effect diff --git a/themes/wind/views/movie.html.php b/themes/wind/views/movie.html.php index 27c293ce..8481c7ce 100644 --- a/themes/wind/views/movie.html.php +++ b/themes/wind/views/movie.html.php @@ -5,8 +5,7 @@ paginator() ?>
- movie_img(array("class" => "g-movie", "id" => "g-movie-id-{$item->id}")) ?> - context_menu($item, "#g-movie-id-{$item->id}") ?> + movie_img(array("class" => "g-movie", "id" => "g-item-id-{$item->id}")) ?>
diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index ebfbf700..4cc949ce 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -89,7 +89,7 @@ diff --git a/themes/wind/views/photo.html.php b/themes/wind/views/photo.html.php index 07952c94..f8b5511c 100644 --- a/themes/wind/views/photo.html.php +++ b/themes/wind/views/photo.html.php @@ -22,7 +22,7 @@ for_html_attr() ?>"> - resize_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize")) ?> + resize_img(array("id" => "g-item-id-{$item->id}", "class" => "g-resize")) ?> -- cgit v1.2.3