@@ -37,7 +37,7 @@ |
||
37 | 37 | * |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - public function clean(TypoScriptFrontendController &$typoScriptFrontend) |
|
40 | + public function clean(TypoScriptFrontendController&$typoScriptFrontend) |
|
41 | 41 | { |
42 | 42 | if ($this->cleanHtmlService instanceof CleanHtmlService) { |
43 | 43 | $configuration = $typoScriptFrontend->config['config']['sourceopt.']; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | if (!empty($config)) { |
72 | 72 | if ($config['formatHtml'] && is_numeric($config['formatHtml'])) { |
73 | - $this->formatType = (int)$config['formatHtml']; |
|
73 | + $this->formatType = (int) $config['formatHtml']; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if ($config['formatHtml.']['tabSize'] && is_numeric($config['formatHtml.']['tabSize'])) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | if (isset($config['formatHtml.']['debugComment'])) { |
81 | - $this->debugComment = (bool)$config['formatHtml.']['debugComment']; |
|
81 | + $this->debugComment = (bool) $config['formatHtml.']['debugComment']; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | if (isset($config['headerComment'])) { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function clean(&$html, $config = []) |
99 | 99 | { |
100 | 100 | if (!empty($config)) { |
101 | - if ((bool)$config['enabled'] === false) { |
|
101 | + if ((bool) $config['enabled'] === false) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | |
108 | 108 | $manipulations = []; |
109 | 109 | |
110 | - if (isset($config['removeGenerator']) && (bool)$config['removeGenerator']) { |
|
110 | + if (isset($config['removeGenerator']) && (bool) $config['removeGenerator']) { |
|
111 | 111 | $manipulations['removeGenerator'] = GeneralUtility::makeInstance(RemoveGenerator::class); |
112 | 112 | } |
113 | 113 | |
114 | - if (isset($config['removeComments']) && (bool)$config['removeComments']) { |
|
114 | + if (isset($config['removeComments']) && (bool) $config['removeComments']) { |
|
115 | 115 | $manipulations['removeComments'] = GeneralUtility::makeInstance(RemoveComments::class); |
116 | 116 | } |
117 | 117 | |
118 | - if (isset($config['removeBlurScript']) && (bool)$config['removeBlurScript']) { |
|
118 | + if (isset($config['removeBlurScript']) && (bool) $config['removeBlurScript']) { |
|
119 | 119 | $manipulations['removeBlurScript'] = GeneralUtility::makeInstance(RemoveBlurScript::class); |
120 | 120 | } |
121 | 121 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | foreach ($manipulations as $key => $manipulation) { |
127 | 127 | /** @var ManipulationInterface $manipulation */ |
128 | - $configuration = isset($config[$key . '.']) && is_array($config[$key . '.']) ? $config[$key . '.'] : []; |
|
128 | + $configuration = isset($config[$key.'.']) && is_array($config[$key.'.']) ? $config[$key.'.'] : []; |
|
129 | 129 | $html = $manipulation->manipulate($html, $configuration); |
130 | 130 | } |
131 | 131 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
170 | 170 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
171 | 171 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
172 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
172 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
173 | 173 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
174 | 174 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
179 | 179 | $html, |
180 | 180 | -1, |
181 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
181 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
182 | 182 | ); |
183 | 183 | // remove empty lines |
184 | 184 | $htmlArray = ['']; |
@@ -205,52 +205,52 @@ discard block |
||
205 | 205 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
206 | 206 | # this element has a line break before itself |
207 | 207 | preg_match( |
208 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
208 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
209 | 209 | $htmlArray[$x] |
210 | 210 | ) || preg_match( |
211 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
211 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
212 | 212 | $htmlArray[$x] |
213 | 213 | ) || # one element before is a element that has a line break after |
214 | 214 | preg_match( |
215 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
215 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
216 | 216 | $htmlArray[$x - 1] |
217 | 217 | ) || substr( |
218 | 218 | $htmlArray[$x - 1], |
219 | 219 | 0, |
220 | 220 | 4 |
221 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
221 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
222 | 222 | ) { |
223 | 223 | $newline = true; |
224 | 224 | } elseif ($this->formatType == 3 && ( // aestetic line break |
225 | 225 | # this element has a line break before itself |
226 | 226 | preg_match( |
227 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
227 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
228 | 228 | $htmlArray[$x] |
229 | 229 | ) || preg_match( |
230 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
230 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
231 | 231 | $htmlArray[$x] |
232 | 232 | ) || # one element before is a element that has a line break after |
233 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
233 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
234 | 234 | $htmlArray[$x - 1], |
235 | 235 | 0, |
236 | 236 | 4 |
237 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
237 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
238 | 238 | ) { |
239 | 239 | $newline = true; |
240 | 240 | } elseif ($this->formatType >= 4 && ( // logical line break |
241 | 241 | # this element has a line break before itself |
242 | 242 | preg_match( |
243 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
243 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
244 | 244 | $htmlArray[$x] |
245 | 245 | ) || preg_match( |
246 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
246 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
247 | 247 | $htmlArray[$x] |
248 | 248 | ) || # one element before is a element that has a line break after |
249 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
249 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
250 | 250 | $htmlArray[$x - 1], |
251 | 251 | 0, |
252 | 252 | 4 |
253 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
253 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
254 | 254 | ) { |
255 | 255 | $newline = true; |
256 | 256 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | // include debug comment at the end |
329 | 329 | if ($tabs != 0 && $this->debugComment === true) { |
330 | - $html .= '<!--' . $tabs . " open elements found-->\r\n"; |
|
330 | + $html .= '<!--'.$tabs." open elements found-->\r\n"; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | 'textarea', |
457 | 457 | 'pre' |
458 | 458 | ]; // eventuell auch: span, script, style |
459 | - $peaces = preg_split('#(<(' . implode('|', $splitArray) . ').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
459 | + $peaces = preg_split('#(<('.implode('|', $splitArray).').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
460 | 460 | $html = ""; |
461 | 461 | for ($i = 0; $i < count($peaces); $i++) { |
462 | 462 | if (($i + 1) % 3 == 0) { |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | public function includeHeaderComment(&$html) |
511 | 511 | { |
512 | 512 | if (!empty($this->headerComment)) { |
513 | - $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function ($matches) { |
|
514 | - return trim($matches[0] . $this->newline . $this->tab . $this->tab . '<!-- ' . $this->headerComment . '-->'); |
|
513 | + $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function($matches) { |
|
514 | + return trim($matches[0].$this->newline.$this->tab.$this->tab.'<!-- '.$this->headerComment.'-->'); |
|
515 | 515 | }, $html, 1); |
516 | 516 | } |
517 | 517 | } |