@@ -22,6 +22,6 @@ |
||
22 | 22 | public function manipulate($html, array $configuration = []) |
23 | 23 | { |
24 | 24 | $regex = '<meta name=["\']?generator["\']? [^>]+>'; |
25 | - return preg_replace('/' . $regex . '/is', '', $html); |
|
25 | + return preg_replace('/'.$regex.'/is', '', $html); |
|
26 | 26 | } |
27 | 27 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | if (!empty($config)) { |
78 | 78 | if ($config['formatHtml'] && is_numeric($config['formatHtml'])) { |
79 | - $this->formatType = (int)$config['formatHtml']; |
|
79 | + $this->formatType = (int) $config['formatHtml']; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if ($config['formatHtml.']['tabSize'] && is_numeric($config['formatHtml.']['tabSize'])) { |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | if (isset($config['formatHtml.']['debugComment'])) { |
87 | - $this->debugComment = (bool)$config['formatHtml.']['debugComment']; |
|
87 | + $this->debugComment = (bool) $config['formatHtml.']['debugComment']; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | if (isset($config['headerComment'])) { |
91 | 91 | $this->headerComment = $config['headerComment']; |
92 | 92 | } |
93 | 93 | |
94 | - if (isset($config['dropEmptySpaceChar']) && (bool)$config['dropEmptySpaceChar']) { |
|
94 | + if (isset($config['dropEmptySpaceChar']) && (bool) $config['dropEmptySpaceChar']) { |
|
95 | 95 | $this->emptySpaceChar = ''; |
96 | 96 | } |
97 | 97 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function clean($html, $config = []) |
109 | 109 | { |
110 | 110 | if (!empty($config)) { |
111 | - if ((bool)$config['enabled'] === false) { |
|
111 | + if ((bool) $config['enabled'] === false) { |
|
112 | 112 | return $html; |
113 | 113 | } |
114 | 114 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | |
118 | 118 | $manipulations = []; |
119 | 119 | |
120 | - if (isset($config['removeGenerator']) && (bool)$config['removeGenerator']) { |
|
120 | + if (isset($config['removeGenerator']) && (bool) $config['removeGenerator']) { |
|
121 | 121 | $manipulations['removeGenerator'] = GeneralUtility::makeInstance(RemoveGenerator::class); |
122 | 122 | } |
123 | 123 | |
124 | - if (isset($config['removeComments']) && (bool)$config['removeComments']) { |
|
124 | + if (isset($config['removeComments']) && (bool) $config['removeComments']) { |
|
125 | 125 | $manipulations['removeComments'] = GeneralUtility::makeInstance(RemoveComments::class); |
126 | 126 | } |
127 | 127 | |
128 | - if (isset($config['removeBlurScript']) && (bool)$config['removeBlurScript']) { |
|
128 | + if (isset($config['removeBlurScript']) && (bool) $config['removeBlurScript']) { |
|
129 | 129 | $manipulations['removeBlurScript'] = GeneralUtility::makeInstance(RemoveBlurScript::class); |
130 | 130 | } |
131 | 131 | |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | |
136 | 136 | foreach ($manipulations as $key => $manipulation) { |
137 | 137 | /** @var ManipulationInterface $manipulation */ |
138 | - $configuration = isset($config[$key . '.']) && is_array($config[$key . '.']) ? $config[$key . '.'] : []; |
|
138 | + $configuration = isset($config[$key.'.']) && is_array($config[$key.'.']) ? $config[$key.'.'] : []; |
|
139 | 139 | $html = $manipulation->manipulate($html, $configuration); |
140 | 140 | } |
141 | 141 | |
142 | 142 | // cleanup HTML5 self-closing elements |
143 | - if(!isset($GLOBALS['TSFE']->config['config']['doctype']) || 'x' !== substr($GLOBALS['TSFE']->config['config']['doctype'],0,1)) { |
|
143 | + if (!isset($GLOBALS['TSFE']->config['config']['doctype']) || 'x' !== substr($GLOBALS['TSFE']->config['config']['doctype'], 0, 1)) { |
|
144 | 144 | $html = preg_replace('/<((?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s[^>]+?)\s?\/>/', '<$1>', $html); |
145 | 145 | } |
146 | 146 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
187 | 187 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
188 | 188 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
189 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
189 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
190 | 190 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
191 | 191 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
192 | 192 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
196 | 196 | $html, |
197 | 197 | -1, |
198 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
198 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
199 | 199 | ); |
200 | 200 | |
201 | 201 | if ($htmlArrayTemp === false) { |
@@ -231,52 +231,52 @@ discard block |
||
231 | 231 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
232 | 232 | # this element has a line break before itself |
233 | 233 | preg_match( |
234 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
234 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
235 | 235 | $htmlArray[$x] |
236 | 236 | ) || preg_match( |
237 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
237 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
238 | 238 | $htmlArray[$x] |
239 | 239 | ) || # one element before is a element that has a line break after |
240 | 240 | preg_match( |
241 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
241 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
242 | 242 | $htmlArray[$x - 1] |
243 | 243 | ) || substr( |
244 | 244 | $htmlArray[$x - 1], |
245 | 245 | 0, |
246 | 246 | 4 |
247 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
247 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
248 | 248 | ) { |
249 | 249 | $newline = true; |
250 | 250 | } elseif ($this->formatType == 3 && ( // aestetic line break |
251 | 251 | # this element has a line break before itself |
252 | 252 | preg_match( |
253 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
253 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
254 | 254 | $htmlArray[$x] |
255 | 255 | ) || preg_match( |
256 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
256 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
257 | 257 | $htmlArray[$x] |
258 | 258 | ) || # one element before is a element that has a line break after |
259 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
259 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
260 | 260 | $htmlArray[$x - 1], |
261 | 261 | 0, |
262 | 262 | 4 |
263 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
263 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
264 | 264 | ) { |
265 | 265 | $newline = true; |
266 | 266 | } elseif ($this->formatType >= 4 && ( // logical line break |
267 | 267 | # this element has a line break before itself |
268 | 268 | preg_match( |
269 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
269 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
270 | 270 | $htmlArray[$x] |
271 | 271 | ) || preg_match( |
272 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
272 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
273 | 273 | $htmlArray[$x] |
274 | 274 | ) || # one element before is a element that has a line break after |
275 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
275 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
276 | 276 | $htmlArray[$x - 1], |
277 | 277 | 0, |
278 | 278 | 4 |
279 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
279 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
280 | 280 | ) { |
281 | 281 | $newline = true; |
282 | 282 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | // include debug comment at the end |
347 | 347 | if ($tabs != 0 && $this->debugComment === true) { |
348 | - $html .= '<!--' . $tabs . " open elements found-->\r\n"; |
|
348 | + $html .= '<!--'.$tabs." open elements found-->\r\n"; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | return $html; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | 'textarea', |
477 | 477 | 'pre' |
478 | 478 | ]; // eventuell auch: span, script, style |
479 | - $peaces = preg_split('#(<(' . implode('|', $splitArray) . ').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
479 | + $peaces = preg_split('#(<('.implode('|', $splitArray).').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
480 | 480 | $html = ""; |
481 | 481 | for ($i = 0; $i < count($peaces); $i++) { |
482 | 482 | if (($i + 1) % 3 == 0) { |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | public function includeHeaderComment(&$html) |
531 | 531 | { |
532 | 532 | if (!empty($this->headerComment)) { |
533 | - $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function ($matches) { |
|
534 | - return trim($matches[0] . $this->newline . $this->tab . $this->tab . '<!-- ' . $this->headerComment . '-->'); |
|
533 | + $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function($matches) { |
|
534 | + return trim($matches[0].$this->newline.$this->tab.$this->tab.'<!-- '.$this->headerComment.'-->'); |
|
535 | 535 | }, $html, 1); |
536 | 536 | } |
537 | 537 | } |