1 | <?php |
||
43 | class ParameterKeepingFormModifier implements FormModifier, CommandPluginAware |
||
44 | { |
||
45 | |||
46 | /** |
||
47 | * Configuration |
||
48 | * |
||
49 | * @var TypoScriptConfiguration |
||
50 | */ |
||
51 | protected $configuration; |
||
52 | |||
53 | /** |
||
54 | * The currently active plugin |
||
55 | * |
||
56 | * @var CommandPluginBase |
||
57 | */ |
||
58 | protected $parentPlugin; |
||
59 | |||
60 | /** |
||
61 | * Constructor |
||
62 | * |
||
63 | */ |
||
64 | 25 | public function __construct() |
|
68 | |||
69 | /** |
||
70 | * Sets the currently active parent plugin. |
||
71 | * |
||
72 | * @param CommandPluginBase $parentPlugin Currently active parent plugin |
||
73 | */ |
||
74 | 25 | public function setParentPlugin(CommandPluginBase $parentPlugin) |
|
78 | |||
79 | /** |
||
80 | * Modifies the search form by providing hidden form fields to transfer |
||
81 | * parameters to a news search. |
||
82 | * |
||
83 | * @param array $markers An array of existing form markers |
||
84 | * @param Template $template An instance of the template engine |
||
85 | * @return array Array with additional markers for suggestions |
||
86 | */ |
||
87 | 25 | public function modifyForm(array $markers, Template $template) |
|
88 | { |
||
89 | 25 | $hiddenFields = []; |
|
90 | |||
91 | 25 | if ($this->parentPlugin instanceof Results && $this->configuration->getSearchKeepExistingParametersForNewSearches()) { |
|
92 | 23 | foreach ($this->parentPlugin->piVars as $key => $value) { |
|
93 | 2 | if ($key == 'page') { |
|
94 | // must reset page |
||
95 | 1 | continue; |
|
96 | } |
||
97 | |||
98 | 1 | $name = $this->parentPlugin->prefixId . '[' . $this->cleanFormValue($key) . ']'; |
|
99 | |||
100 | 1 | if (is_array($value)) { |
|
101 | 1 | foreach ($value as $k => $v) { |
|
102 | 1 | $hiddenFields[] = '<input type="hidden" name="' . $name . '[' . $this->cleanFormValue($k) . ']" value="' . $this->cleanFormValue($v) . '" />'; |
|
103 | } |
||
104 | } else { |
||
105 | 1 | $hiddenFields[] = '<input type="hidden" name="' . $name . '" value="' . $this->cleanFormValue($value) . '" />'; |
|
106 | } |
||
107 | } |
||
108 | } |
||
109 | |||
110 | 25 | $markers['hidden_parameter_fields'] = implode("\n", $hiddenFields); |
|
111 | |||
112 | 25 | return $markers; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Cleans a form value that needs to be carried over to the next request |
||
117 | * from potential XSS. |
||
118 | * |
||
119 | * @param string $value Possibly malicious form field value |
||
120 | * @return string Cleaned value |
||
121 | */ |
||
122 | 1 | private function cleanFormValue($value) |
|
131 | } |
||
132 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.