1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 14:30:32 +02:00

[ticket/10328] Added a JSON class.

The JSON class adds a consistent way to send JSON to the client, making
it perfect for AJAX (jQuery automatically parses it).

PHPBB3-10328
This commit is contained in:
Callum Macrae
2011-08-19 10:45:03 +01:00
committed by Igor Wiedler
parent 94172b54dd
commit dce38f44de
5 changed files with 63 additions and 9 deletions

View File

@@ -2713,7 +2713,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
if ($request->is_ajax())
{
$u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id;
echo json_encode(array(
JSON::send(array(
'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title],
'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'],
@@ -2721,7 +2721,6 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function
'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields
));
exit;
}
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
@@ -3951,14 +3950,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
{
global $refresh_data;
echo json_encode(array(
JSON::send(array(
'MESSAGE_TITLE' => $msg_title,
'MESSAGE_TEXT' => $msg_text,
'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false,
'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false,
'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null
));
exit;
}
// We do not want the cron script to be called on error messages