Commit 1de6ee68 authored by dawehner's avatar dawehner Committed by tim.plunkett
Browse files

Issue #1613170 by dawehner, tim.plunkett, gaspaio, aspilicious | bojanz: Update for HttpKernel.

parent acbb3bcf
......@@ -134,7 +134,7 @@ function views_ui_preview($view, $display_id, $args = array()) {
// be in GET. Copy stuff but remove ajax-framework specific keys.
// If we're clicking on links in a preview, though, we could actually
// still have some in $_GET, so we use $_REQUEST to ensure we get it all.
$exposed_input = $_REQUEST;
$exposed_input = drupal_container()->get('request')->request->all();
foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) {
if (isset($exposed_input[$key])) {
unset($exposed_input[$key]);
......@@ -731,10 +731,12 @@ function views_ui_add_form_store_edit_submit($form, &$form_state) {
// If there is a destination query, ensure we still redirect the user to the
// edit view page, and then redirect the user to the destination.
// @todo: Revisit this when http://drupal.org/node/1668866 is in.
$destination = array();
if (isset($_GET['destination'])) {
$query = drupal_container()->get('request')->query;
if ($query->has('destination')) {
$destination = drupal_get_destination();
unset($_GET['destination']);
$query->remove('destination');
}
$form_state['redirect'] = array('admin/structure/views/view/' . $view->name, array('query' => $destination));
}
......@@ -840,9 +842,9 @@ function views_ui_break_lock_confirm($form, &$form_state, $view) {
return $form;
}
$cancel = 'admin/structure/views/view/' . $view->name . '/edit';
if (!empty($_REQUEST['cancel'])) {
$cancel = $_REQUEST['cancel'];
$cancel = drupal_container()->get('request')->query->get('cancel');
if (empty($cancel)) {
$cancel = 'admin/structure/views/view/' . $view->name . '/edit';
}
$account = user_load($view->locked->ownerId);
......@@ -917,10 +919,6 @@ function views_ui_edit_page($view, $display_id = NULL) {
}
function views_ui_build_preview($view, $display_id, $render = TRUE) {
if (isset($_POST['ajax_html_ids'])) {
unset($_POST['ajax_html_ids']);
}
$build = array(
'#theme_wrappers' => array('container'),
'#attributes' => array('id' => 'views-preview-wrapper', 'class' => 'views-admin clearfix'),
......@@ -1146,7 +1144,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) {
// If relationships had to be fixed, we want to get that into the cache
// so that edits work properly, and to try to get the user to save it
// so that it's not using weird fixed up relationships.
if (!empty($view->relationships_changed) && empty($_POST)) {
if (!empty($view->relationships_changed) && drupal_container()->get('request')->request->count()) {
drupal_set_message(t('This view has been automatically updated to fix missing relationships. While this View should continue to work, you should verify that the automatic updates are correct and save this view.'));
views_ui_cache_set($view);
}
......@@ -1420,7 +1418,10 @@ function views_ui_edit_form_submit_preview($form, &$form_state) {
* should not yet redirect to the destination.
*/
function views_ui_edit_form_submit_delay_destination($form, &$form_state) {
if (isset($_GET['destination']) && $form_state['redirect'] !== FALSE) {
$query = drupal_container()->get('request')->query;
// @todo: Revisit this when http://drupal.org/node/1668866 is in.
$destination = $query->get('destination');
if (isset($destination) && $form_state['redirect'] !== FALSE) {
if (!isset($form_state['redirect'])) {
$form_state['redirect'] = current_path();
}
......@@ -1429,10 +1430,10 @@ function views_ui_edit_form_submit_delay_destination($form, &$form_state) {
}
$options = isset($form_state['redirect'][1]) ? $form_state['redirect'][1] : array();
if (!isset($options['query']['destination'])) {
$options['query']['destination'] = $_GET['destination'];
$options['query']['destination'] = $destination;
}
$form_state['redirect'][1] = $options;
unset($_GET['destination']);
$query->remove('destination');
}
}
......@@ -2122,8 +2123,10 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
}
// Direct the user to the right url, if the path of the display has changed.
if (!empty($_GET['destination'])) {
$destination = $_GET['destination'];
$query = drupal_container()->get('request')->query;
// @todo: Revisit this when http://drupal.org/node/1668866 is in.
$destination = $query->get('destination');
if (!empty($destination)) {
// Find out the first display which has a changed path and redirect to this url.
$old_view = views_get_view($form_state['view']->name);
foreach ($old_view->display as $id => $display) {
......@@ -2134,7 +2137,7 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
$old_path = $display->display_options['path'];
if (($display->display_plugin == 'page') && ($old_path == $destination) && ($old_path != $form_state['view']->display[$id]->display_options['path'])) {
$destination = $form_state['view']->display[$id]->display_options['path'];
unset($_GET['destination']);
$query->remove('destination');
}
}
$form_state['redirect'] = $destination;
......@@ -2161,7 +2164,11 @@ function views_ui_edit_view_form_cancel($form, &$form_state) {
}
function views_ui_edit_view_form_delete($form, &$form_state) {
unset($_REQUEST['destination']);
$request = drupal_container()->get('request')->request;
// @todo: Revisit this when http://drupal.org/node/1668866 is in.
if ($request->get('destination') !== NULL) {
$request->remove('destination');
}
// Redirect to the delete confirm page
$form_state['redirect'] = array('admin/structure/views/view/' . $form_state['view']->name . '/delete', array('query' => drupal_get_destination() + array('cancel' => 'admin/structure/views/view/' . $form_state['view']->name . '/edit')));
}
......@@ -2870,12 +2877,6 @@ function views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FAL
* together.
*/
function views_ui_ajax_form($js, $key, $view, $display_id = '') {
// Reset the cache of IDs. Drupal rather aggressively prevents id duplication
// but this causes it to remember IDs that are no longer even being used.
if (isset($_POST['ajax_html_ids'])) {
unset($_POST['ajax_html_ids']);
}
$form = views_ui_ajax_forms($key);
if (empty($form)) {
return MENU_NOT_FOUND;
......@@ -5071,7 +5072,7 @@ function views_ui_autocomplete_tag($string = '') {
}
}
drupal_json_output($matches);
return new JsonResponse($matches);
}
// ------------------------------------------------------------------
......
......@@ -15,26 +15,28 @@
* Menu callback to load a view via AJAX.
*/
function views_ajax() {
if (isset($_REQUEST['view_name']) && isset($_REQUEST['view_display_id'])) {
$name = $_REQUEST['view_name'];
$display_id = $_REQUEST['view_display_id'];
$args = isset($_REQUEST['view_args']) && $_REQUEST['view_args'] !== '' ? explode('/', $_REQUEST['view_args']) : array();
$path = isset($_REQUEST['view_path']) ? rawurldecode($_REQUEST['view_path']) : NULL;
$dom_id = isset($_REQUEST['view_dom_id']) ? preg_replace('/[^a-zA-Z0-9_-]+/', '-', $_REQUEST['view_dom_id']) : NULL;
$pager_element = isset($_REQUEST['pager_element']) ? intval($_REQUEST['pager_element']) : NULL;
$request = drupal_container()->get('request');
$name = $request->request->get('view_name');
$display_id = $request->request->get('view_display_id');
if (isset($name) && isset($display_id)) {
$args = $request->request->get('view_args');
$args = isset($args) && $args !== '' ? explode('/', $args) : array();
$path = $request->request->get('view_path');
$dom_id = $request->request->get('view_dom_id');
$dom_id = isset($dom_id) ? preg_replace('/[^a-zA-Z0-9_-]+/', '-', $dom_id) : NULL;
$pager_element = $request->request->get('pager_element');
$pager_element = isset($pager_element) ? intval($pager_element) : NULL;
$commands = array();
// Remove all of this stuff from $_GET so it doesn't end up in pagers and tablesort URLs.
// Remove all of this stuff from the query of the request so it doesn't end
// up in pagers and tablesort URLs.
foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state') as $key) {
if (isset($_GET[$key])) {
unset($_GET[$key]);
if ($request->query->has($key)) {
$request->query->remove($key);
}
if (isset($_REQUEST[$key])) {
unset($_REQUEST[$key]);
}
if (isset($_POST[$key])) {
unset($_POST[$key]);
if ($request->request->has($key)) {
$request->request->remove($key);
}
}
......@@ -48,12 +50,14 @@ function views_ajax() {
// Add all $_POST data, because AJAX is always a post and many things,
// such as tablesorts, exposed filters and paging assume $_GET.
$_GET = $_POST + $_GET;
$request_all = $request->request->all();
$query_all = $request->query->all();
$request->query->replace($request_all + $query_all);
// Overwrite the destination.
// @see drupal_get_destination()
$origin_destination = $path;
$query = drupal_http_build_query($_REQUEST);
$query = drupal_http_build_query($request->query->all());
if ($query != '') {
$origin_destination .= '?' . $query;
}
......@@ -313,7 +317,7 @@ function views_ajax_autocomplete_user($string = '') {
}
}
drupal_json_output($matches);
return new JsonResponse($matches);
}
/**
......@@ -366,7 +370,7 @@ function views_ajax_autocomplete_taxonomy($vid, $tags_typed = '') {
}
}
drupal_json_output($term_matches);
return new JsonResponse($term_matches);
}
/**
......
......@@ -1707,8 +1707,8 @@ function options_form(&$form, &$form_state) {
$form['#title'] .= t('Theming information');
$form['#help_topic'] = 'analyze-theme';
if (isset($_POST['theme'])) {
$this->theme = $_POST['theme'];
if ($theme = drupal_container()->get('request')->request->get('theme')) {
$this->theme = $theme;
}
elseif (empty($this->theme)) {
$this->theme = variable_get('theme_default', 'bartik');
......
......@@ -1465,7 +1465,7 @@ function get_render_tokens($item) {
}
// Get flattened set of tokens for any array depth in $_GET parameters.
$tokens += $this->get_token_values_recursive($_GET);
$tokens += $this->get_token_values_recursive(drupal_container()->get('request')->query->all());
// Now add replacements for our fields.
foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
......
......@@ -261,16 +261,20 @@ function options_validate(&$form, &$form_state) {
function query() {
if ($this->items_per_page_exposed()) {
if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) {
$this->options['items_per_page'] = $_GET['items_per_page'];
$query = drupal_container()->get('request')->query;
$items_per_page = $query->get('items_per_page');
if ($items_per_page > 0) {
$this->options['items_per_page'] = $items_per_page;
}
elseif (!empty($_GET['items_per_page']) && $_GET['items_per_page'] == 'All' && $this->options['expose']['items_per_page_options_all']) {
elseif ($items_per_page == 'All' && $this->options['expose']['items_per_page_options_all']) {
$this->options['items_per_page'] = 0;
}
}
if ($this->offset_exposed()) {
if (isset($_GET['offset']) && $_GET['offset'] >= 0) {
$this->options['offset'] = $_GET['offset'];
$query = drupal_container()->get('request')->query;
$offset = $query->get('offset');
if (isset($offset) && $offset >= 0) {
$this->options['offset'] = $offset;
}
}
......@@ -328,7 +332,8 @@ function set_current_page($number = NULL) {
// Fill in missing values in the global page array, in case the global page
// array hasn't been initialized before.
$page = isset($_GET['page']) ? explode(',', $_GET['page']) : array();
$page = drupal_container()->get('request')->query->get('page');
$page = isset($page) ? explode(',', $page) : array();
for ($i = 0; $i <= $this->options['id'] || $i < count($pager_page_array); $i++) {
$pager_page_array[$i] = empty($page[$i]) ? 0 : $page[$i];
......
......@@ -81,12 +81,13 @@ function option_definition() {
* @return bool
*/
function build_sort() {
if (!isset($_GET['order']) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) {
$order = drupal_container()->get('request')->query->get('order');
if (!isset($order) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) {
return TRUE;
}
// If a sort we don't know anything about gets through, exit gracefully.
if (isset($_GET['order']) && empty($this->view->field[$_GET['order']])) {
if (isset($order) && empty($this->view->field[$order])) {
return TRUE;
}
......@@ -98,7 +99,9 @@ function build_sort() {
* Add our actual sort criteria
*/
function build_sort_post() {
if (!isset($_GET['order'])) {
$query = drupal_container()->get('request')->query;
$order = $query->get('order');
if (!isset($order)) {
// check for a 'default' clicksort. If there isn't one, exit gracefully.
if (empty($this->options['default'])) {
return;
......@@ -112,9 +115,10 @@ function build_sort_post() {
}
}
else {
$sort = $_GET['order'];
$sort = $order;
// Store the $order for later use.
$this->order = !empty($_GET['sort']) ? strtolower($_GET['sort']) : 'asc';
$request_sort = $query->get('sort');
$this->order = !empty($request_sort) ? strtolower($request_sort) : 'asc';
}
// If a sort we don't know anything about gets through, exit gracefully.
......
......@@ -435,7 +435,7 @@ function get_exposed_input() {
// Fill our input either from $_GET or from something previously set on the
// view.
if (empty($this->exposed_input)) {
$this->exposed_input = $_GET;
$this->exposed_input = drupal_container()->get('request')->query->all();
// unset items that are definitely not our input:
foreach (array('page', 'q') as $key) {
if (isset($this->exposed_input[$key])) {
......
......@@ -41,7 +41,7 @@ function render($values) {
}
function render_link($data, $values) {
$language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$tnid = $this->get_value($values, 'tnid');
// Only load translations if the node isn't in the current language.
......
......@@ -254,7 +254,7 @@ function list_build_row($view, &$form_state, $operations) {
function list_render(&$form_state) {
views_include('admin');
views_ui_add_admin_css();
if (empty($_REQUEST['js'])) {
if (!drupal_container()->get('request')->request->get('js')) {
views_ui_check_advanced_help();
}
drupal_add_library('system', 'jquery.bbq');
......@@ -263,7 +263,7 @@ function list_render(&$form_state) {
$this->active = $form_state['values']['order'];
$this->order = $form_state['values']['sort'];
$query = tablesort_get_query_parameters();
$query = tablesort_get_query_parameters();
$header = array(
$this->tablesort_link(t('View name'), 'name', 'views-ui-name'),
......
......@@ -2122,7 +2122,8 @@ function views_exposed_form($form, &$form_state) {
}
$form['submit'] = array(
'#name' => '', // prevent from showing up in $_GET.
// Prevent from showing up in $_GET.
'#name' => '',
'#type' => 'submit',
'#value' => t('Apply'),
'#id' => drupal_html_id('edit-submit-' . $view->name),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment