Prechádzať zdrojové kódy

Allow a bit more articulated reports to moderator (textarea instead of input and preserving of new-lines) but keeping the 255 chars limit [Topic 426962]

Signed-off-by: emanuele <[email protected]>
emanuele 12 rokov pred
rodič
commit
32548ae349

+ 1 - 1
Sources/ModerationCenter.php

@@ -880,7 +880,7 @@ function ModReport()
 	{
 		$context['report']['comments'][] = array(
 			'id' => $row['id_comment'],
-			'message' => $row['comment'],
+			'message' => strtr($row['comment'], array("\n" => '<br />')),
 			'time' => timeformat($row['time_sent']),
 			'member' => array(
 				'id' => $row['id_member'],

+ 28 - 2
Sources/SendTopic.php

@@ -335,6 +335,29 @@ function ReportToModerator()
 	loadLanguage('Post');
 	loadTemplate('SendTopic');
 
+	addInlineJavascript('
+	var error_box = $("#error_box");
+	$("#report_comment").keyup(function() {
+		var post_too_long = $("#error_post_too_long");
+		if ($(this).val().length > 254)
+		{
+			if (post_too_long.length == 0)
+			{
+				error_box.show();
+				if ($.trim(error_box.html()) == \'\')
+					error_box.append("<ul id=\'error_list\'></ul>");
+
+				$("#error_list").append("<li id=\'error_post_too_long\' class=\'error\'>" + ' . JavaScriptEscape($txt['post_too_long']) . ' + "</li>");
+			}
+		}
+		else
+		{
+			post_too_long.remove();
+			if ($("#error_list li").length == 0)
+				error_box.hide();
+		}
+	});', true);
+
 	$context['comment_body'] = !isset($_POST['comment']) ? '' : trim($_POST['comment']);
 	$context['email_address'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
 
@@ -375,7 +398,10 @@ function ReportToModerator2()
 	// Make sure we have a comment and it's clean.
 	if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '')
 		$post_errors[] = 'no_comment';
-	$poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\n" => '', "\t" => ''));
+	$poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => ''));
+
+	if ($smcFunc['strlen']($poster_comment) > 254)
+		$post_errors[] = 'post_too_long';
 
 	// Guests need to provide their address!
 	if ($user_info['is_guest'])
@@ -410,7 +436,7 @@ function ReportToModerator2()
 
 		$context['post_errors'] = array();
 		foreach ($post_errors as $post_error)
-			$context['post_errors'][] = $txt['error_' . $post_error];
+			$context['post_errors'][$post_error] = $txt['error_' . $post_error];
 
 		return ReportToModerator();
 	}

+ 13 - 8
Themes/default/SendTopic.template.php

@@ -209,18 +209,23 @@ function template_report()
 
 	if (!empty($context['post_errors']))
 	{
-		echo '
-				<div class="errorbox">
-					<ul>';
+	echo '
+				<div id="error_box" class="errorbox">
+					<ul id="error_list">';
 
-		foreach ($context['post_errors'] as $error)
+		foreach ($context['post_errors'] as $key => $error)
 			echo '
-						<li class="error">', $error, '</li>';
+						<li id="error_', $key, '" class="error">', $error, '</li>';
 
 		echo '
-					</ul>
-				</div>';
+					</ul>';
 	}
+	else
+		echo '
+				<div style="display:none" id="error_box" class="errorbox">';
+
+		echo '
+				</div>';
 
 	echo '
 						<p class="noticebox">', $txt['report_to_mod_func'], '</p>
@@ -243,7 +248,7 @@ function template_report()
 								<label for="report_comment">', $txt['enter_comment'], '</label>:
 							</dt>
 							<dd>
-								<input type="text" id="report_comment" name="comment" size="50" value="', $context['comment_body'], '" maxlength="255" />
+								<textarea type="text" id="report_comment" name="comment" style="width: 70%" rows="5">', $context['comment_body'], '</textarea>
 							</dd>';
 
 	if ($context['require_verification'])

+ 2 - 0
Themes/default/languages/Errors.english.php

@@ -240,6 +240,8 @@ $txt['error_no_question'] = 'No question was filled in for this poll.';
 $txt['error_no_message'] = 'The message body was left empty.';
 $txt['error_long_message'] = 'The message exceeds the maximum allowed length (%1$d characters).';
 $txt['error_no_comment'] = 'The comment field was left empty.';
+// duplicate of post_too_long in Post.{language}.php
+$txt['error_post_too_long'] = 'Your message is too long. Please go back and shorten it, then try again.';
 $txt['error_session_timeout'] = 'Your session timed out while posting. Please try to re-submit your message.';
 $txt['error_no_to'] = 'No recipients specified.';
 $txt['error_bad_to'] = 'One or more \'to\'-recipients could not be found.';

+ 1 - 0
Themes/default/languages/Post.english.php

@@ -67,6 +67,7 @@ $txt['right_align'] = 'Right align';
 $txt['superscript'] = 'Superscript';
 $txt['subscript'] = 'Subscript';
 $txt['table_tr'] = 'Insert table row';
+// post_too_long seems unused (duplicate in Errors: error_post_too_long
 $txt['post_too_long'] = 'Your message is too long. Please go back and shorten it, then try again.';
 $txt['horizontal_rule'] = 'Horizontal Rule';
 $txt['font_size'] = 'Font size';