本文整理汇总了PHP中phpbb\request\request::is_ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP request::is_ajax方法的具体用法?PHP request::is_ajax怎么用?PHP request::is_ajax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request
的用法示例。
在下文中一共展示了request::is_ajax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
/**
* Controller for mChat actions called with Ajax requests
*
* @param $action The action to perform, one of add|edit|del|clean|refresh|whois
* @return A Symfony JsonResponse object
*/
public function action($action)
{
if (!$this->request->is_ajax()) {
throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
}
$data = call_user_func(array($this->mchat, 'action_' . $action));
return new JsonResponse($data);
}
示例2: handle
/**
* {@inheritdoc}
*/
public function handle($forum_id)
{
// Throw an exception for non-AJAX requests or invalid link requests
if (!$this->request->is_ajax() || !$this->is_valid($forum_id) || !check_link_hash($this->request->variable('hash', ''), 'collapsible_' . $forum_id)) {
throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
}
// Update the user's collapsed category data for the given forum
$response = $this->operator->set_user_categories($forum_id);
// Return a JSON response
return new \Symfony\Component\HttpFoundation\JsonResponse(array('success' => $response));
}
示例3: get_userlist
/**
* Mentions controller accessed from the URL /mentions/user_list
*
* @return null
* @access public
*/
public function get_userlist()
{
// Send a JSON response if an AJAX request was used
if ($this->request->is_ajax()) {
// If we have a query_string, we just get those usernames
$query_string = $this->request->variable('term', '') ? $this->request->variable('term', '') : false;
$user_list = $this->mentions->get_userlist($query_string);
$user_list = array_values($user_list);
$json_response = new \phpbb\json_response();
$json_response->send($user_list);
}
}
示例4: ajax_delete_result_message
/**
* Show user a result message if AJAX was used
*
* @param string $message Text message to show to the user
*
* @return null
* @access protected
*/
protected function ajax_delete_result_message($message = '')
{
if ($this->request->is_ajax()) {
$json_response = new \phpbb\json_response();
$json_response->send(array('MESSAGE_TITLE' => $this->user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'REFRESH_DATA' => array('time' => 3)));
}
}
示例5: handle
/**
* Controller for mChat
*
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
public function handle()
{
$ret = $this->render_helper->render_data_for_page();
// If this was an ajax request, we just create an json_response and return that. It's not ours to handle here.
if ($this->request->is_ajax() && is_array($ret) && isset($ret['json']) && $ret['json'] === true) {
return new \Symfony\Component\HttpFoundation\JsonResponse($ret);
}
// If error occured, render it
if (isset($ret['error']) && $ret['error'] == true) {
return $this->helper->error($ret['error_text'], $ret['error_type']);
}
return $this->helper->render($ret['filename'], $ret['lang_title']);
}
示例6: post
/**
* Post a new message to the shoutbox.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function post()
{
// We always disallow guests to post in the shoutbox.
if (!$this->auth->acl_get('u_shoutbox_post') || $this->user->data['user_id'] == ANONYMOUS) {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_NO_PERMISSION', 403);
}
if ($this->request->is_ajax()) {
$message = $msg = trim(utf8_normalize_nfc($this->request->variable('text_shoutbox', '', true)));
if (empty($message)) {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_MESSAGE_EMPTY', 500);
}
$uid = $bitfield = $options = '';
$allow_bbcode = $this->auth->acl_get('u_shoutbox_bbcode');
$allow_urls = $allow_smilies = true;
if (!function_exists('generate_text_for_storage')) {
include $this->root_path . 'includes/functions_content.' . $this->php_ext;
}
generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
$insert = array('post_message' => $message, 'post_time' => time(), 'user_id' => $this->user->data['user_id'], 'bbcode_options' => $options, 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid);
$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', $insert);
$this->db->sql_query($sql);
if ($this->push->canPush()) {
// User configured us to submit the shoutbox post to the iOS/Android app
$this->push->post($msg, $insert['post_time'], $this->user->data['username'], $this->db->sql_nextid());
}
return new JsonResponse(array('OK'));
} else {
return $this->error('AJAX_SHOUTBOX_ERROR', 'AJAX_SHOUTBOX_ONLY_AJAX', 500);
}
}
示例7: bbcode_wizard
/**
* BBCode wizard controller accessed with the URL /wizard/bbcode/{mode}
* (where {mode} is a placeholder for a string of the bbcode tag name)
* intended to be accessed via AJAX only
*
* @param string $mode Mode taken from the URL
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @throws \phpbb\exception\http_exception An http exception
* @access public
*/
public function bbcode_wizard($mode)
{
// Only allow AJAX requests
if ($this->request->is_ajax()) {
switch ($mode) {
case 'bbvideo':
$this->generate_bbvideo_wizard();
return $this->helper->render('abbc3_bbvideo_wizard.html');
break;
case 'url':
return $this->helper->render('abbc3_url_wizard.html');
break;
}
}
throw new \phpbb\exception\http_exception(404, 'GENERAL_ERROR');
}
示例8: test_is_ajax_with_ajax
public function test_is_ajax_with_ajax()
{
$this->request->enable_super_globals();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->request = new \phpbb\request\request($this->type_cast_helper);
$this->assertTrue($this->request->is_ajax());
}
示例9: action_move
/**
* Move order categories
*
* @return null
*/
public function action_move()
{
if (!$this->cat_id) {
trigger_error($this->user->lang['DIR_NO_CAT'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
}
$sql = 'SELECT cat_id, cat_name, parent_id, left_id, right_id
FROM ' . DIR_CAT_TABLE . '
WHERE cat_id = ' . (int) $this->cat_id;
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!$row) {
trigger_error($this->user->lang['DIR_NO_CAT'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING);
}
try {
$move_cat_name = $this->nestedset_category->{$this->action}($this->cat_id);
} catch (\Exception $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
}
if ($move_cat_name !== false) {
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_' . strtoupper($this->action), time(), array($row['cat_name'], $move_cat_name));
$this->cache->destroy('sql', DIR_CAT_TABLE);
}
if ($this->request->is_ajax()) {
$json_response = new \phpbb\json_response();
$json_response->send(array('success' => $move_cat_name !== false));
}
}
示例10: deleteAccount
/**
* Удаление привязки к аккаунту соцсети в таблице ulogin_user для текущего пользователя
*/
protected function deleteAccount()
{
if (!$this->request->is_ajax()) {
$redirect = "{$this->root_path}index.{$this->php_ext}";
$redirect = append_sid($redirect);
redirect($redirect);
}
if (!$this->isUserLogined) {
exit;
}
$user_id = $this->currentUserId;
$network = $this->request->variable('network', '', false, \phpbb\request\request_interface::POST);
if ($user_id > 0 && $network != '') {
try {
$this->model->deleteUloginUser(array('user_id' => $user_id, 'network' => $network));
$json_response = new \phpbb\json_response();
$json_response->send(array('title' => '', 'msg' => sprintf($this->user->lang['ULOGIN_DELETE_ACCOUNT_SUCCESS'], $network), 'type' => 'success'));
exit;
} catch (Exception $e) {
$json_response = new \phpbb\json_response();
$json_response->send(array('title' => $this->user->lang['ULOGIN_DELETE_ACCOUNT_ERROR'], 'msg' => "Exception: " . $e->getMessage(), 'type' => 'error'));
exit;
}
}
exit;
}
示例11: drag_drop
/**
* Update BBCode order fields in the db on drag_drop
*
* @return null
* @access public
*/
public function drag_drop()
{
if (!$this->request->is_ajax()) {
return;
}
// Get the bbcodes html table's name
$tablename = $this->request->variable('tablename', '');
// Fetch the posted list
$bbcodes_list = $this->request->variable($tablename, array(0 => ''));
$this->db->sql_transaction('begin');
// Run through the list
foreach ($bbcodes_list as $order => $bbcode_id) {
// First one is the header, skip it
if ($order == 0) {
continue;
}
// Update the db
$sql = 'UPDATE ' . BBCODES_TABLE . '
SET bbcode_order = ' . $order . '
WHERE bbcode_id = ' . (int) $bbcode_id;
$this->db->sql_query($sql);
}
$this->db->sql_transaction('commit');
// Resync bbcode_order
$this->resynchronize_bbcode_order();
// return an AJAX JSON response
$json_response = new \phpbb\json_response();
$json_response->send(array('success' => true));
}
示例12: clear_user
/**
* Clear user reputation
*
* @param int $uid User ID
* @return null
* @access public
*/
public function clear_user($uid)
{
$this->user->add_lang_ext('pico/reputation', 'reputation_system');
$is_ajax = $this->request->is_ajax();
$submit = false;
$sql_array = array('SELECT' => 'r.*, ut.username AS username_to', 'FROM' => array($this->reputations_table => 'r'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'ut'), 'ON' => 'r.user_id_to = ut.user_id ')), 'WHERE' => 'r.user_id_to = ' . $uid);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
//We couldn't find this reputation. May be it was deleted meanwhile?
if (empty($row)) {
$message = $this->user->lang('RS_NO_REPUTATION');
$json_data = array('error_msg' => $message);
$redirect = append_sid("{$this->root_path}index.{$this->php_ext}");
$redirect_text = 'RETURN_INDEX';
$this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
}
$redirect = $this->helper->route('reputation_details_controller', array('uid' => $uid));
if ($this->request->is_set_post('cancel')) {
redirect($redirect);
}
$post_ids = array();
$post_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');
$sql = 'SELECT reputation_item_id
FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$uid}\n\t\t\t\tAND reputation_type_id = {$post_type_id}\n\t\t\tGROUP BY reputation_item_id";
$result = $this->db->sql_query($sql);
while ($post_row = $this->db->sql_fetchrow($result)) {
$post_ids[] = $post_row['reputation_item_id'];
}
$this->db->sql_freeresult($result);
$redirect_text = 'RETURN_PAGE';
if ($this->auth->acl_gets('m_rs_moderate')) {
if ($is_ajax) {
$submit = true;
} else {
$s_hidden_fields = build_hidden_fields(array('u' => $uid));
if (confirm_box(true)) {
$submit = true;
} else {
confirm_box(false, $this->user->lang('RS_CLEAR_POST_CONFIRM'), $s_hidden_fields);
}
}
} else {
$message = $this->user->lang('RS_USER_CANNOT_DELETE');
$json_data = array('error_msg' => $message);
$this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
}
if ($submit) {
try {
$this->reputation_manager->clear_user_reputation($uid, $row, $post_ids);
} catch (\pico\reputation\exception\base $e) {
// Catch exception
trigger_error($e->get_message($this->user));
}
$message = $this->user->lang('RS_CLEARED_USER');
$json_data = array('clear_user' => true, 'post_ids' => $post_ids, 'poster_id' => $uid, 'user_reputation' => 0, 'post_reputation' => 0, 'reputation_class' => 'neutral');
$this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
}
}
示例13: return_date
/**
* date controller for return a date
*
* @return \phpbb\json_response A Json Response
* @throws \phpbb\exception\http_exception
*/
public function return_date()
{
if (!$this->request->is_ajax()) {
throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
}
$timestamp = $this->request->variable('timestamp', 0);
$json_response = new \phpbb\json_response();
$json_response->send(array('success' => true, 'DATE' => $this->user->format_date((int) $timestamp)));
}
示例14: display_overview
/**
* Display reputation overview
*
* @return null
* @access public
*/
public function display_overview()
{
add_form_key('overview');
$errors = array();
$action = $this->request->variable('action', '');
if (!confirm_box(true)) {
$confirm = false;
switch ($action) {
case 'sync':
$confirm = true;
$confirm_lang = 'RS_SYNC_REPUTATION_CONFIRM';
break;
case 'truncate':
$confirm = true;
$confirm_lang = 'RS_TRUNCATE_CONFIRM';
break;
}
if ($confirm) {
confirm_box(false, $this->user->lang($confirm_lang), build_hidden_fields(array('action' => $action)));
}
} else {
switch ($action) {
case 'sync':
$this->config->set('rs_sync_step', 1, true);
// Get sync module ID
$sql = 'SELECT module_id
FROM ' . MODULES_TABLE . "\n\t\t\t\t\t\tWHERE module_basename LIKE '%reputation%'\n\t\t\t\t\t\t\tAND module_mode = 'sync'";
$result = $this->db->sql_query($sql);
$sync_module_id = (int) $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
// Redirect to hidden sync module
redirect(append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", "i={$sync_module_id}&mode=sync"));
break;
case 'truncate':
$this->db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_reputation = 0');
$this->db->sql_query('UPDATE ' . POSTS_TABLE . ' SET post_reputation = 0');
$this->db->sql_query('TRUNCATE ' . $this->reputations_table);
add_log('admin', 'LOG_REPUTATION_TRUNCATE');
if ($this->request->is_ajax()) {
trigger_error('RS_TRUNCATE_DONE');
}
break;
}
}
if ($this->request->is_set_post('submit')) {
if (!check_form_key('overview')) {
$errors[] = $this->user->lang('FORM_INVALID');
}
if (empty($errors)) {
$this->config->set('rs_enable', $this->request->variable('reputation_enable', 0));
}
add_log('admin', 'REPUTATION_SETTINGS_CHANGED');
trigger_error($this->user->lang('REPUTATION_SETTINGS_CHANGED') . adm_back_link($this->u_action));
}
$this->template->assign_vars(array('S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => implode('<br />', $errors), 'S_REPUTATION_ENABLED' => $this->config['rs_enable'] ? true : false, 'S_FOUNDER' => $this->user->data['user_type'] == USER_FOUNDER ? true : false, 'U_ACTION' => $this->u_action));
}
示例15: output_ajax_post_preview
/**
* Alter preview output for ajax request
*
* @param object $event The event object
* @return null
* @access public
*/
public function output_ajax_post_preview($event)
{
if ($this->request->is_ajax() && $event['preview']) {
if (empty($event['message_parser']->message)) {
exit_handler();
} else {
if (sizeof($event['error'])) {
// seems to be the best HTTP code
header('HTTP/1.1 412 Precondition Failed');
echo implode('<br />', $event['error']);
exit_handler();
} else {
$this->template->assign_vars($event['page_data']);
// we can't use helper's render method, because it refreshes the page
page_header('');
$this->template->set_filenames(array('body' => '@senky_ajaxbase/ajax_posting_preview.html'));
page_footer();
}
}
}
}