@@ -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 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | if (!empty($config)) { |
| 70 | 70 | if ($config['formatHtml'] && is_numeric($config['formatHtml'])) { |
| 71 | - $this->formatType = (int)$config['formatHtml']; |
|
| 71 | + $this->formatType = (int) $config['formatHtml']; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if ($config['formatHtml.']['tabSize'] && is_numeric($config['formatHtml.']['tabSize'])) { |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if (isset($config['formatHtml.']['debugComment'])) { |
| 79 | - $this->debugComment = (bool)$config['formatHtml.']['debugComment']; |
|
| 79 | + $this->debugComment = (bool) $config['formatHtml.']['debugComment']; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if (isset($config['headerComment'])) { |
| 83 | 83 | $this->headerComment = $config['headerComment']; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if (isset($config['dropEmptySpaceChar']) && (bool)$config['dropEmptySpaceChar']) { |
|
| 86 | + if (isset($config['dropEmptySpaceChar']) && (bool) $config['dropEmptySpaceChar']) { |
|
| 87 | 87 | $this->emptySpaceChar = ''; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | public function clean($html, $config = []) |
| 101 | 101 | { |
| 102 | 102 | if (!empty($config)) { |
| 103 | - if ((bool)$config['enabled'] === false) { |
|
| 103 | + if ((bool) $config['enabled'] === false) { |
|
| 104 | 104 | return $html; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $manipulations = []; |
| 113 | 113 | |
| 114 | - if (isset($config['removeGenerator']) && (bool)$config['removeGenerator']) { |
|
| 114 | + if (isset($config['removeGenerator']) && (bool) $config['removeGenerator']) { |
|
| 115 | 115 | $manipulations['removeGenerator'] = GeneralUtility::makeInstance(RemoveGenerator::class); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if (isset($config['removeComments']) && (bool)$config['removeComments']) { |
|
| 118 | + if (isset($config['removeComments']) && (bool) $config['removeComments']) { |
|
| 119 | 119 | $manipulations['removeComments'] = GeneralUtility::makeInstance(RemoveComments::class); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -125,12 +125,12 @@ 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 | |
| 132 | 132 | // cleanup HTML5 self-closing elements |
| 133 | - if(!isset($GLOBALS['TSFE']->config['config']['doctype']) || 'x' !== substr($GLOBALS['TSFE']->config['config']['doctype'],0,1)) { |
|
| 133 | + if (!isset($GLOBALS['TSFE']->config['config']['doctype']) || 'x' !== substr($GLOBALS['TSFE']->config['config']['doctype'], 0, 1)) { |
|
| 134 | 134 | $html = preg_replace('/<((?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s[^>]+?)\s?\/>/', '<$1>', $html); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
| 184 | 184 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
| 185 | 185 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
| 186 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
| 186 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
| 187 | 187 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
| 188 | 188 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
| 189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
| 193 | 193 | $html, |
| 194 | 194 | -1, |
| 195 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 195 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | 198 | if ($htmlArrayTemp === false) { |
@@ -227,52 +227,52 @@ discard block |
||
| 227 | 227 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
| 228 | 228 | # this element has a line break before itself |
| 229 | 229 | preg_match( |
| 230 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 230 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 231 | 231 | $htmlArray[$x] |
| 232 | 232 | ) || preg_match( |
| 233 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
| 233 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
| 234 | 234 | $htmlArray[$x] |
| 235 | 235 | ) || # one element before is a element that has a line break after |
| 236 | 236 | preg_match( |
| 237 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 237 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 238 | 238 | $htmlArray[$x - 1] |
| 239 | 239 | ) || substr( |
| 240 | 240 | $htmlArray[$x - 1], |
| 241 | 241 | 0, |
| 242 | 242 | 4 |
| 243 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 243 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 244 | 244 | ) { |
| 245 | 245 | $newline = true; |
| 246 | 246 | } elseif ($this->formatType == 3 && ( // aestetic line break |
| 247 | 247 | # this element has a line break before itself |
| 248 | 248 | preg_match( |
| 249 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
| 249 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
| 250 | 250 | $htmlArray[$x] |
| 251 | 251 | ) || preg_match( |
| 252 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
| 252 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
| 253 | 253 | $htmlArray[$x] |
| 254 | 254 | ) || # one element before is a element that has a line break after |
| 255 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 255 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 256 | 256 | $htmlArray[$x - 1], |
| 257 | 257 | 0, |
| 258 | 258 | 4 |
| 259 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 259 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 260 | 260 | ) { |
| 261 | 261 | $newline = true; |
| 262 | 262 | } elseif ($this->formatType >= 4 && ( // logical line break |
| 263 | 263 | # this element has a line break before itself |
| 264 | 264 | preg_match( |
| 265 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
| 265 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
| 266 | 266 | $htmlArray[$x] |
| 267 | 267 | ) || preg_match( |
| 268 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
| 268 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
| 269 | 269 | $htmlArray[$x] |
| 270 | 270 | ) || # one element before is a element that has a line break after |
| 271 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 271 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 272 | 272 | $htmlArray[$x - 1], |
| 273 | 273 | 0, |
| 274 | 274 | 4 |
| 275 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 275 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 276 | 276 | ) { |
| 277 | 277 | $newline = true; |
| 278 | 278 | } |
@@ -430,6 +430,6 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | public function includeHeaderComment(&$html) |
| 432 | 432 | { |
| 433 | - $html = preg_replace('/^(-->)$/m', "\n\t" . $this->headerComment . "\n$1", $html); |
|
| 433 | + $html = preg_replace('/^(-->)$/m', "\n\t".$this->headerComment."\n$1", $html); |
|
| 434 | 434 | } |
| 435 | 435 | } |