diff --git a/app/Helpers/ConfigHelper.php b/app/Helpers/ConfigHelper.php index 35132f4..b6c0ebe 100644 --- a/app/Helpers/ConfigHelper.php +++ b/app/Helpers/ConfigHelper.php @@ -113,6 +113,7 @@ class ConfigHelper 'items_per_page' => 12, 'items_per_page_admin' => 10, 'photo_comments_require_login' => true, + 'photo_comments_thread_depth' => 3, 'public_statistics' => true, 'recaptcha_enabled_registration' => false, 'recaptcha_secret_key' => '', diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 9fcd35a..f4f5aea 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -254,6 +254,7 @@ class DefaultController extends Controller 'facebook_app_secret', 'google_app_id', 'google_app_secret', + 'photo_comments_thread_depth', 'sender_address', 'sender_name', 'smtp_server', diff --git a/app/PhotoComment.php b/app/PhotoComment.php index dec829a..a666603 100644 --- a/app/PhotoComment.php +++ b/app/PhotoComment.php @@ -26,4 +26,23 @@ class PhotoComment extends Model { return $this->belongsTo(User::class, 'created_user_id'); } + + public function depth() + { + $depth = 0; + $current = $this; + + while (!is_null($current->parent)) + { + $current = $current->parent; + $depth++; + } + + return $depth; + } + + public function parent() + { + return $this->belongsTo(PhotoComment::class, 'parent_comment_id'); + } } \ No newline at end of file diff --git a/resources/assets/js/gallery.js b/resources/assets/js/gallery.js new file mode 100644 index 0000000..5ce3145 --- /dev/null +++ b/resources/assets/js/gallery.js @@ -0,0 +1,22 @@ +/** + * This model is used by gallery/photo.blade.php, to handle comments and individual photo actions. + * @constructor + */ +function PhotoViewModel() { + this.el = '#photo-app'; + + this.data = { + is_reply_form_loading: false, + reply_comment_id: 0 + }; + + this.methods = { + replyToComment: function(e) { + var replyButton = $(e.target).closest('.photo-comment'); + this.reply_comment_id = replyButton.data('comment-id'); + + this.is_reply_form_loading = true; + $('#comment-reply-modal').modal('show'); + } + }; +} \ No newline at end of file diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 4bb7b50..6353b65 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -202,6 +202,15 @@ return [ 'security_heading' => 'Permissions', 'security_text' => 'You can assign permissions on this album to either groups (recommended) or directly to users.', 'security_users_heading' => 'User Permissions', + 'select_all_action' => 'Select all', + 'select_all_album_active' => 'Any action you select in the list below will apply to all photos in this album.', + 'select_all_choice' => [ + 'all_action' => 'All in this album', + 'message' => 'Do you want to select all the photos in the album, or just those that are visible on this page?', + 'title' => 'Select all in album?', + 'visible_action' => 'Only those visible' + ], + 'select_none_action' => 'Clear selection', 'settings' => [ 'albums_menu_heading' => 'Albums Navigation Menu', 'albums_menu_number_items' => 'Number of albums to display:', @@ -213,6 +222,7 @@ return [ 'analytics_enable_visitor_hits' => 'Enable built-in visitor hit tracking', 'analytics_enable_visitor_hits_description' => 'Visitor hits to the public gallery will be recorded in the Blue Twilight database, allowing for analysis such as the most popular album/photo.', 'analytics_tab' => 'Analytics', + 'comments_tab' => 'Comments', 'permissions_cache' => 'Permissions Cache', 'permissions_cache_intro' => 'Blue Twilight maintains the permissions each user has to albums in the database. If you feel these aren\'t correct based on what\'s configured, you can rebuild the cache by clicking the button below.', 'rebuild_permissions_cache' => 'Rebuild Permissions Cache', @@ -225,15 +235,6 @@ return [ 'social_tab' => 'Social', 'social_twitter' => 'Twitter' ], - 'select_all_action' => 'Select all', - 'select_all_album_active' => 'Any action you select in the list below will apply to all photos in this album.', - 'select_all_choice' => [ - 'all_action' => 'All in this album', - 'message' => 'Do you want to select all the photos in the album, or just those that are visible on this page?', - 'title' => 'Select all in album?', - 'visible_action' => 'Only those visible' - ], - 'select_none_action' => 'Clear selection', 'settings_email_tab' => 'E-mail', 'settings_general_tab' => 'General', 'settings_security_tab' => 'Security', diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index a45679b..0b45424 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -52,6 +52,8 @@ return [ 'select_current_text' => '(current)', 'settings_allow_photo_comments' => 'Allow comments on photos', 'settings_allow_photo_comments_help' => 'With this option enabled, users can comment on individual photos.', + 'settings_photo_comments_thread_depth' => 'Maximum depth for nested comments:', + 'settings_photo_comments_thread_depth_help' => 'Set to zero to disable nested comments.', 'settings_photo_comments_require_login' => 'Require login before posting comments', 'settings_photo_comments_require_login_help' => 'If this option is enabled, users must login before they can post comments.', 'settings_hotlink_protection' => 'Prevent hot-linking to images', diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index 301cb06..84dca7e 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -35,8 +35,10 @@ return [ 'other_albums_heading' => 'More Albums in :album_name', 'photo_comment_posted_successfully' => 'Your comment was posted successfully and will appear after it has been moderated.', 'photo_comments_heading' => 'Comments', + 'photo_comments_reply_action' => 'Reply', 'photo_comments_reply_form_heading' => 'Leave a reply', 'photo_comments_reply_form_p1' => 'Complete the form below to start a new reply thread.', + 'photo_comments_reply_modal_title' => 'Reply to comment', 'photos' => 'photo|photos', 'previous_button' => '« Previous Photo', 'show_more_albums' => '... and :count other|... and :count others', diff --git a/resources/views/themes/base/admin/settings.blade.php b/resources/views/themes/base/admin/settings.blade.php index 34675ac..0628075 100644 --- a/resources/views/themes/base/admin/settings.blade.php +++ b/resources/views/themes/base/admin/settings.blade.php @@ -24,6 +24,7 @@ @include(Theme::viewName('partials.tab'), ['active_tab' => 'general', 'tab_name' => 'security', 'tab_icon' => 'lock', 'tab_text' => trans('admin.settings_security_tab')]) @include(Theme::viewName('partials.tab'), ['active_tab' => 'general', 'tab_name' => 'analytics', 'tab_icon' => 'line-chart', 'tab_text' => trans('admin.settings.analytics_tab')]) @include(Theme::viewName('partials.tab'), ['active_tab' => 'general', 'tab_name' => 'social', 'tab_icon' => 'users', 'tab_text' => trans('admin.settings.social_tab')]) + @include(Theme::viewName('partials.tab'), ['active_tab' => 'general', 'tab_name' => 'comments', 'tab_icon' => 'edit', 'tab_text' => trans('admin.settings.comments_tab')]) {{-- Tab panes --}} @@ -329,22 +330,6 @@ {{-- Social --}}
-
- - -
- -
- - -
-
+ + {{-- Comments tab --}} +
+
+ + +
+ +
+ + +
+ +
+ + + @lang('forms.settings_photo_comments_thread_depth_help') + + @if ($errors->has('photo_comments_thread_depth')) +
+ {{ $errors->first('photo_comments_thread_depth') }} +
+ @endif +
+
diff --git a/resources/views/themes/base/gallery/photo.blade.php b/resources/views/themes/base/gallery/photo.blade.php index d945288..af75a89 100644 --- a/resources/views/themes/base/gallery/photo.blade.php +++ b/resources/views/themes/base/gallery/photo.blade.php @@ -10,7 +10,7 @@ @endsection @section('content') -
+

{{ $photo->name }}

@@ -157,4 +157,14 @@
-@endsection \ No newline at end of file +@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/themes/base/partials/photo_comments.blade.php b/resources/views/themes/base/partials/photo_comments.blade.php index d4a9445..9b6c9a2 100644 --- a/resources/views/themes/base/partials/photo_comments.blade.php +++ b/resources/views/themes/base/partials/photo_comments.blade.php @@ -10,12 +10,32 @@ @if ($photo->approvedComments()->count() > 0) @endif
+
+ + \ No newline at end of file diff --git a/resources/views/themes/base/partials/photo_single_comment.blade.php b/resources/views/themes/base/partials/photo_single_comment.blade.php new file mode 100644 index 0000000..f4e4a6d --- /dev/null +++ b/resources/views/themes/base/partials/photo_single_comment.blade.php @@ -0,0 +1,8 @@ +
  • + Comment by {{ $comment->createdBy->name }}:
    + {{ $comment->comment_text }} + + @if ($comment->depth() < UserConfig::get('photo_comments_thread_depth')) +

    + @endif +
  • \ No newline at end of file