@@ -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; |
| 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,7 +135,7 @@ 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 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
| 180 | 180 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
| 181 | 181 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
| 182 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
| 182 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
| 183 | 183 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
| 184 | 184 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
| 185 | 185 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
| 189 | 189 | $html, |
| 190 | 190 | -1, |
| 191 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 191 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
| 192 | 192 | ); |
| 193 | 193 | // remove empty lines |
| 194 | 194 | $htmlArray = ['']; |
@@ -215,52 +215,52 @@ discard block |
||
| 215 | 215 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
| 216 | 216 | # this element has a line break before itself |
| 217 | 217 | preg_match( |
| 218 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 218 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 219 | 219 | $htmlArray[$x] |
| 220 | 220 | ) || preg_match( |
| 221 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
| 221 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
| 222 | 222 | $htmlArray[$x] |
| 223 | 223 | ) || # one element before is a element that has a line break after |
| 224 | 224 | preg_match( |
| 225 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 225 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 226 | 226 | $htmlArray[$x - 1] |
| 227 | 227 | ) || substr( |
| 228 | 228 | $htmlArray[$x - 1], |
| 229 | 229 | 0, |
| 230 | 230 | 4 |
| 231 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 231 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 232 | 232 | ) { |
| 233 | 233 | $newline = true; |
| 234 | 234 | } elseif ($this->formatType == 3 && ( // aestetic line break |
| 235 | 235 | # this element has a line break before itself |
| 236 | 236 | preg_match( |
| 237 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
| 237 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
| 238 | 238 | $htmlArray[$x] |
| 239 | 239 | ) || preg_match( |
| 240 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
| 240 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
| 241 | 241 | $htmlArray[$x] |
| 242 | 242 | ) || # one element before is a element that has a line break after |
| 243 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 243 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 244 | 244 | $htmlArray[$x - 1], |
| 245 | 245 | 0, |
| 246 | 246 | 4 |
| 247 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 247 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 248 | 248 | ) { |
| 249 | 249 | $newline = true; |
| 250 | 250 | } elseif ($this->formatType >= 4 && ( // logical line break |
| 251 | 251 | # this element has a line break before itself |
| 252 | 252 | preg_match( |
| 253 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
| 253 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
| 254 | 254 | $htmlArray[$x] |
| 255 | 255 | ) || preg_match( |
| 256 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
| 256 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
| 257 | 257 | $htmlArray[$x] |
| 258 | 258 | ) || # one element before is a element that has a line break after |
| 259 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 259 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 260 | 260 | $htmlArray[$x - 1], |
| 261 | 261 | 0, |
| 262 | 262 | 4 |
| 263 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 263 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 264 | 264 | ) { |
| 265 | 265 | $newline = true; |
| 266 | 266 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | // include debug comment at the end |
| 339 | 339 | if ($tabs != 0 && $this->debugComment === true) { |
| 340 | - $html .= '<!--' . $tabs . " open elements found-->\r\n"; |
|
| 340 | + $html .= '<!--'.$tabs." open elements found-->\r\n"; |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | 'textarea', |
| 467 | 467 | 'pre' |
| 468 | 468 | ]; // eventuell auch: span, script, style |
| 469 | - $peaces = preg_split('#(<(' . implode('|', $splitArray) . ').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 469 | + $peaces = preg_split('#(<('.implode('|', $splitArray).').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 470 | 470 | $html = ""; |
| 471 | 471 | for ($i = 0; $i < count($peaces); $i++) { |
| 472 | 472 | if (($i + 1) % 3 == 0) { |
@@ -520,8 +520,8 @@ discard block |
||
| 520 | 520 | public function includeHeaderComment(&$html) |
| 521 | 521 | { |
| 522 | 522 | if (!empty($this->headerComment)) { |
| 523 | - $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function ($matches) { |
|
| 524 | - return trim($matches[0] . $this->newline . $this->tab . $this->tab . '<!-- ' . $this->headerComment . '-->'); |
|
| 523 | + $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function($matches) { |
|
| 524 | + return trim($matches[0].$this->newline.$this->tab.$this->tab.'<!-- '.$this->headerComment.'-->'); |
|
| 525 | 525 | }, $html, 1); |
| 526 | 526 | } |
| 527 | 527 | } |