@@ -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,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 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
| 182 | 182 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
| 183 | 183 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
| 184 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
| 184 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
| 185 | 185 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
| 186 | 186 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
| 187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
| 191 | 191 | $html, |
| 192 | 192 | -1, |
| 193 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 193 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | if ($htmlArrayTemp === false) { |
@@ -221,52 +221,52 @@ discard block |
||
| 221 | 221 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
| 222 | 222 | # this element has a line break before itself |
| 223 | 223 | preg_match( |
| 224 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 224 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 225 | 225 | $htmlArray[$x] |
| 226 | 226 | ) || preg_match( |
| 227 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
| 227 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
| 228 | 228 | $htmlArray[$x] |
| 229 | 229 | ) || # one element before is a element that has a line break after |
| 230 | 230 | preg_match( |
| 231 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 231 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 232 | 232 | $htmlArray[$x - 1] |
| 233 | 233 | ) || substr( |
| 234 | 234 | $htmlArray[$x - 1], |
| 235 | 235 | 0, |
| 236 | 236 | 4 |
| 237 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 237 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 238 | 238 | ) { |
| 239 | 239 | $newline = true; |
| 240 | 240 | } elseif ($this->formatType == 3 && ( // aestetic line break |
| 241 | 241 | # this element has a line break before itself |
| 242 | 242 | preg_match( |
| 243 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
| 243 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
| 244 | 244 | $htmlArray[$x] |
| 245 | 245 | ) || preg_match( |
| 246 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
| 246 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
| 247 | 247 | $htmlArray[$x] |
| 248 | 248 | ) || # one element before is a element that has a line break after |
| 249 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 249 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 250 | 250 | $htmlArray[$x - 1], |
| 251 | 251 | 0, |
| 252 | 252 | 4 |
| 253 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 253 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 254 | 254 | ) { |
| 255 | 255 | $newline = true; |
| 256 | 256 | } elseif ($this->formatType >= 4 && ( // logical line break |
| 257 | 257 | # this element has a line break before itself |
| 258 | 258 | preg_match( |
| 259 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
| 259 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
| 260 | 260 | $htmlArray[$x] |
| 261 | 261 | ) || preg_match( |
| 262 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
| 262 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
| 263 | 263 | $htmlArray[$x] |
| 264 | 264 | ) || # one element before is a element that has a line break after |
| 265 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 265 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 266 | 266 | $htmlArray[$x - 1], |
| 267 | 267 | 0, |
| 268 | 268 | 4 |
| 269 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 269 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 270 | 270 | ) { |
| 271 | 271 | $newline = true; |
| 272 | 272 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | // include debug comment at the end |
| 337 | 337 | if ($tabs != 0 && $this->debugComment === true) { |
| 338 | - $html .= '<!--' . $tabs . " open elements found-->\r\n"; |
|
| 338 | + $html .= '<!--'.$tabs." open elements found-->\r\n"; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | return $html; |
@@ -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 | } |