Browse Source

Got rid of $context['post_error']['messages']

Signed-off-by: John Rayes <[email protected]>
John Rayes 12 years ago
parent
commit
c89ad72715
3 changed files with 7 additions and 11 deletions
  1. 3 7
      Sources/Post.php
  2. 2 2
      Themes/default/Post.template.php
  3. 2 2
      Themes/default/Xml.template.php

+ 3 - 7
Sources/Post.php

@@ -410,8 +410,6 @@ function Post($post_errors = array())
 		if ($smcFunc['strlen']($form_subject) > 100)
 			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
 
-		$context['post_error'] = array('messages' => array());
-
 		/*
 		 * There are two error types: serious and miinor. Serious errors
 		 * actually tell the user that a real error has occurred, while minor
@@ -431,8 +429,7 @@ function Post($post_errors = array())
 				if (is_array($post_error))
 				{
 					$post_error_id = $post_error[0];
-					$context['post_error'][$post_error_id] = true;
-					$context['post_error']['messages'][] = sprintf($txt['error_' . $post_error_id], $post_error[1]);
+					$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
 
 					// If it's not a minor error flag it as such.
 					if (!in_array($post_error_id, $minor_errors))
@@ -440,8 +437,7 @@ function Post($post_errors = array())
 				}
 				else
 				{
-					$context['post_error'][$post_error] = true;
-					$context['post_error']['messages'][] = $txt['error_' . $post_error];
+					$context['post_error'][$post_error] = $txt['error_' . $post_error];
 
 					// If it's not a minor error flag it as such.
 					if (!in_array($post_error, $minor_errors))
@@ -1711,7 +1707,7 @@ function Post2()
 	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
 		$post_errors[] = 'no_message';
 	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
-		$post_errors[] = 'long_message';
+		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
 	else
 	{
 		// Prepare the message a bit for some additional testing.

+ 2 - 2
Themes/default/Post.template.php

@@ -100,13 +100,13 @@ function template_main()
 
 	// If an error occurred, explain what happened.
 	echo '
-					<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
+					<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']) ? ' style="display: none"' : '', ' id="errors">
 						<dl>
 							<dt>
 								<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
 							</dt>
 							<dd class="error" id="error_list">
-								', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
+								', empty($context['post_error']) ? '' : implode('<br />', $context['post_error']), '
 							</dd>
 						</dl>
 					</div>';

+ 2 - 2
Themes/default/Xml.template.php

@@ -98,8 +98,8 @@ function template_post()
 		<body><![CDATA[', $context['preview_message'], ']]></body>
 	</preview>
 	<errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">';
-	if (!empty($context['post_error']['messages']))
-		foreach ($context['post_error']['messages'] as $message)
+	if (!empty($context['post_error']))
+		foreach ($context['post_error'] as $message)
 			echo '
 		<error><![CDATA[', cleanXml($message), ']]></error>';
 	echo '