ViewsAddButtonTrait.php in Views Add Button 8
File
src/Plugin/views/ViewsAddButtonTrait.php
View source
<?php
namespace Drupal\views_add_button\Plugin\views;
trait ViewsAddButtonTrait {
public function viewsAddButtonCleanupSpecialCharacters($str = '') {
$replace = [
'%5B' => '[',
'%5D' => ']',
'&' => '&',
];
return strtr($str, $replace);
}
public function getQueryString($values = NULL) {
$query_string = $this->options['query_string'];
$q = NULL;
if (isset($value->index)) {
$q = $this->options['tokenize'] ? $this
->tokenizeValue($query_string, $values->index) : $query_string;
}
else {
$q = $this->options['tokenize'] ? $this
->tokenizeValue($query_string) : $query_string;
}
$query_opts = [];
if ($q) {
$q = $this
->viewsAddButtonCleanupSpecialCharacters($q);
$qparts = explode('&', $q);
foreach ($qparts as $part) {
$p = explode('=', $part);
if (is_array($p) && count($p) > 1) {
$query_opts[$p[0]] = $p[1];
}
}
}
return $query_opts;
}
}