MDL-65675 forum: Remove duplicate Re in subjects

This commit is contained in:
Andrew Nicols 2019-05-22 11:04:51 +08:00
parent 383aec8a01
commit 9ba09a1244
8 changed files with 22 additions and 5 deletions

View File

@ -1 +1 @@
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(f){f.on("click",d.post.inpageReplyLink,function(f){if(f.preventDefault(),window.location.hash){var g=window.location.href.split("#")[0];history.pushState({},document.title,g)}var h=a(f.currentTarget).parents(d.post.forumCoreContent),i=h.find(d.post.forumSubject),j=a(f.currentTarget).parents(d.post.forumContent),k={postid:a(j).data("post-id"),reply_url:a(f.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:i.html(),canreplyprivately:a(f.currentTarget).data("can-reply-privately"),postformat:e.CONTENT_FORMATS.MOODLE};if(j.find(d.post.inpageReplyContent).length){var l=j.find(d.post.inpageReplyContent);l.slideToggle(300),l.is(":visible")&&l.find("textarea").focus()}else b.render("mod_forum/inpage_reply",k).then(function(a,c){return b.appendNodeContents(h,a,c)}).then(function(){return j.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});
define(["jquery","core/templates","core/notification","mod_forum/selectors","mod_forum/inpage_reply"],function(a,b,c,d,e){var f=function(f){f.on("click",d.post.inpageReplyLink,function(f){if(f.preventDefault(),window.location.hash){var g=window.location.href.split("#")[0];history.pushState({},document.title,g)}var h=a(f.currentTarget).parents(d.post.forumCoreContent),i=h.find(d.post.forumSubject),j=a(f.currentTarget).parents(d.post.forumContent),k={postid:a(j).data("post-id"),reply_url:a(f.currentTarget).attr("href"),sesskey:M.cfg.sesskey,parentsubject:i.data("replySubject"),canreplyprivately:a(f.currentTarget).data("can-reply-privately"),postformat:e.CONTENT_FORMATS.MOODLE};if(j.find(d.post.inpageReplyContent).length){var l=j.find(d.post.inpageReplyContent);l.slideToggle(300),l.is(":visible")&&l.find("textarea").focus()}else b.render("mod_forum/inpage_reply",k).then(function(a,c){return b.appendNodeContents(h,a,c)}).then(function(){return j.find(d.post.inpageReplyContent).slideToggle(300).find("textarea").focus()}).fail(c.exception)})};return{init:function(a){f(a),e.init(a)}}});

View File

@ -59,7 +59,7 @@ define([
postid: $(currentRoot).data('post-id'),
"reply_url": $(e.currentTarget).attr('href'),
sesskey: M.cfg.sesskey,
parentsubject: currentSubject.html(),
parentsubject: currentSubject.data('replySubject'),
canreplyprivately: $(e.currentTarget).data('can-reply-privately'),
postformat: InPageReply.CONTENT_FORMATS.MOODLE
};

View File

@ -92,6 +92,7 @@ class post extends exporter {
return [
'id' => ['type' => PARAM_INT],
'subject' => ['type' => PARAM_TEXT],
'replysubject' => ['type' => PARAM_TEXT],
'message' => ['type' => PARAM_RAW],
'messageformat' => ['type' => PARAM_INT],
'author' => ['type' => author_exporter::read_properties_definition()],
@ -401,9 +402,16 @@ class post extends exporter {
}
}
$replysubject = $subject;
$strre = get_string('re', 'forum');
if (!(substr($replysubject, 0, strlen($strre)) == $strre)) {
$replysubject = "{$strre} {$replysubject}";
}
return [
'id' => $post->get_id(),
'subject' => $subject,
'replysubject' => $replysubject,
'message' => $message,
'messageformat' => $post->get_message_format(),
'author' => $exportedauthor,

View File

@ -0,0 +1 @@
inpagereplysubject,mod_forum

View File

@ -323,7 +323,6 @@ $string['invalidforcesubscribe'] = 'Invalid force subscription mode';
$string['invalidforumid'] = 'Forum ID was incorrect';
$string['invalidparentpostid'] = 'Parent post ID was incorrect';
$string['invalidpostid'] = 'Invalid post ID - {$a}';
$string['inpagereplysubject'] = 'Re: {$a}';
$string['lastpost'] = 'Last post';
$string['learningforums'] = 'Learning forums';
$string['lockdiscussionafter'] = 'Lock discussions after period of inactivity';
@ -673,3 +672,6 @@ $string['yournewtopic'] = 'Your new discussion topic';
$string['yourreply'] = 'Your reply';
$string['forumsubjectdeleted'] = 'This forum post has been removed';
$string['forumbodydeleted'] = 'The content of this forum post has been removed and can no longer be accessed.';
// Deprecated since Moodle 3.8.
$string['inpagereplysubject'] = 'Re: {$a}';

View File

@ -67,7 +67,11 @@
{{#parentauthorname}}
<span class="sr-only">{{#str}} inreplyto, mod_forum, {{.}} {{/str}}</span>
{{/parentauthorname}}
<h3 class="h6 font-weight-bold mb-0" data-region-content="forum-post-core-subject">{{$subject}}{{{subject}}}{{/subject}}</h3>
<h3 {{!
}}class="h6 font-weight-bold mb-0" {{!
}}data-region-content="forum-post-core-subject" {{!
}}data-reply-subject="{{replysubject}}" {{!
}}>{{$subject}}{{{subject}}}{{/subject}}</h3>
{{^isdeleted}}
<address tabindex="-1">
{{#html.authorsubheading}}{{{.}}}{{/html.authorsubheading}}

View File

@ -41,7 +41,7 @@
<textarea rows="5" name="post" title="post" class="w-100" placeholder="{{#str}} replyplaceholder, forum {{/str}}"></textarea>
<input type="hidden" name="postformat" value="{{postformat}}"/>
</span>
<input type="hidden" name="subject" value="{{#str}} inpagereplysubject, forum, {{parentsubject}} {{/str}}"/>
<input type="hidden" name="subject" value="{{parentsubject}}"/>
<input type="hidden" name="reply" value="{{postid}}"/>
<input type="hidden" name="sesskey" value="{{sesskey}}"/>
</div>

View File

@ -668,6 +668,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
'hasparent' => true,
'timecreated' => $discussion1reply2->created,
'subject' => $discussion1reply2->subject,
'replysubject' => get_string('re', 'mod_forum') . " {$discussion1reply2->subject}",
'message' => file_rewrite_pluginfile_urls($discussion1reply2->message, 'pluginfile.php',
$forum1context->id, 'mod_forum', 'post', $discussion1reply2->id),
'messageformat' => 1, // This value is usually changed by external_format_text() function.
@ -721,6 +722,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
'hasparent' => true,
'timecreated' => $discussion1reply1->created,
'subject' => $discussion1reply1->subject,
'replysubject' => get_string('re', 'mod_forum') . " {$discussion1reply1->subject}",
'message' => file_rewrite_pluginfile_urls($discussion1reply1->message, 'pluginfile.php',
$forum1context->id, 'mod_forum', 'post', $discussion1reply1->id),
'messageformat' => 1, // This value is usually changed by external_format_text() function.