mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-29 21:10:31 +02:00
[ticket/10270] Added JavaScript popups and basic AJAX functionality to PHP.
This commit adds the phpbb object (JavaScript), and alert and confirm box methods. It also adds the first basic AJAX functionality, to deleting posts in viewtopic. PHPBB3-10270
This commit is contained in:
committed by
Igor Wiedler
parent
4f97cc1295
commit
d420ceb9c7
@@ -2448,15 +2448,25 @@ function build_url($strip_vars = false)
|
||||
*/
|
||||
function meta_refresh($time, $url, $disable_cd_check = false)
|
||||
{
|
||||
global $template;
|
||||
global $template, $refresh_data;
|
||||
|
||||
$url = redirect($url, true, $disable_cd_check);
|
||||
$url = str_replace('&', '&', $url);
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
|
||||
{
|
||||
$refresh_data = array(
|
||||
'time' => $time,
|
||||
'url' => str_replace('&', '&', $url)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = redirect($url, true, $disable_cd_check);
|
||||
$url = str_replace('&', '&', $url);
|
||||
|
||||
// For XHTML compatibility we change back & to &
|
||||
$template->assign_vars(array(
|
||||
'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />')
|
||||
);
|
||||
// For XHTML compatibility we change back & to &
|
||||
$template->assign_vars(array(
|
||||
'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />')
|
||||
);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
@@ -2699,6 +2709,21 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
|
||||
WHERE user_id = " . $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
|
||||
{
|
||||
$u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id;
|
||||
echo json_encode(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'],
|
||||
|
||||
'YES_VALUE' => $user->lang['YES'],
|
||||
'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'])
|
||||
{
|
||||
adm_page_footer();
|
||||
@@ -3922,6 +3947,20 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
||||
'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false)
|
||||
);
|
||||
|
||||
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
|
||||
{
|
||||
global $refresh_data;
|
||||
|
||||
echo json_encode(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
|
||||
define('IN_CRON', true);
|
||||
|
||||
|
Reference in New Issue
Block a user