@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | if (!empty($config)) { |
| 76 | 76 | if ($config['formatHtml'] && is_numeric($config['formatHtml'])) { |
| 77 | - $this->formatType = (int)$config['formatHtml']; |
|
| 77 | + $this->formatType = (int) $config['formatHtml']; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if ($config['formatHtml.']['tabSize'] && is_numeric($config['formatHtml.']['tabSize'])) { |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (isset($config['enable_utf'])) { |
| 85 | - $this->utf8 = (bool)$config['enable_utf-8_support']; |
|
| 85 | + $this->utf8 = (bool) $config['enable_utf-8_support']; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if (isset($config['formatHtml.']['debugComment'])) { |
| 89 | - $this->debugComment = (bool)$config['formatHtml.']['debugComment']; |
|
| 89 | + $this->debugComment = (bool) $config['formatHtml.']['debugComment']; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if (isset($config['headerComment'])) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | public function clean(&$html, $config = []) |
| 107 | 107 | { |
| 108 | 108 | if (!empty($config)) { |
| 109 | - if ((bool)$config['enabled'] === false) { |
|
| 109 | + if ((bool) $config['enabled'] === false) { |
|
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -115,15 +115,15 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $manipulations = []; |
| 117 | 117 | |
| 118 | - if (isset($config['removeGenerator']) && (bool)$config['removeGenerator']) { |
|
| 118 | + if (isset($config['removeGenerator']) && (bool) $config['removeGenerator']) { |
|
| 119 | 119 | $manipulations['removeGenerator'] = GeneralUtility::makeInstance('HTML\\Sourceopt\\Manipulation\\RemoveGenerator'); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if (isset($config['removeComments']) && (bool)$config['removeComments']) { |
|
| 122 | + if (isset($config['removeComments']) && (bool) $config['removeComments']) { |
|
| 123 | 123 | $manipulations['removeComments'] = GeneralUtility::makeInstance('HTML\\Sourceopt\\Manipulation\\RemoveComments'); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if (isset($config['removeBlurScript']) && (bool)$config['removeBlurScript']) { |
|
| 126 | + if (isset($config['removeBlurScript']) && (bool) $config['removeBlurScript']) { |
|
| 127 | 127 | $manipulations['removeBlurScript'] = GeneralUtility::makeInstance('HTML\\Sourceopt\\Manipulation\\RemoveBlurScript'); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | foreach ($manipulations as $key => $manipulation) { |
| 135 | 135 | /** @var ManipulationInterface $manipulation */ |
| 136 | - $configuration = isset($config[$key . '.']) && is_array($config[$key . '.']) ? $config[$key . '.'] : []; |
|
| 136 | + $configuration = isset($config[$key.'.']) && is_array($config[$key.'.']) ? $config[$key.'.'] : []; |
|
| 137 | 137 | $html = $manipulation->manipulate($html, $configuration); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $functionalBoxElements = 'dd|dt|frameset|li|tbody|td|tfoot|th|thead|tr|colgroup'; |
| 178 | 178 | $usableBoxElements = 'applet|button|del|iframe|ins|map|object|script'; |
| 179 | 179 | $imagineBoxElements = 'html|body|head|meta|title|link|script|base|!--'; |
| 180 | - $allBoxLikeElements = '(?>' . $trueBoxElements . '|' . $functionalBoxElements . '|' . $usableBoxElements . '|' . $imagineBoxElements . ')'; |
|
| 180 | + $allBoxLikeElements = '(?>'.$trueBoxElements.'|'.$functionalBoxElements.'|'.$usableBoxElements.'|'.$imagineBoxElements.')'; |
|
| 181 | 181 | $esteticBoxLikeElements = '(?>html|head|body|meta name|title|div|table|h1|h2|h3|h4|h5|h6|p|form|pre|center|!--)'; |
| 182 | 182 | $structureBoxLikeElements = '(?>html|head|body|div|!--)'; |
| 183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', |
| 187 | 187 | $html, |
| 188 | 188 | -1, |
| 189 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 189 | + PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY |
|
| 190 | 190 | ); |
| 191 | 191 | // remove empty lines |
| 192 | 192 | $htmlArray = ['']; |
@@ -213,52 +213,52 @@ discard block |
||
| 213 | 213 | } elseif ($this->formatType == 2 && ( // minimalistic line break |
| 214 | 214 | # this element has a line break before itself |
| 215 | 215 | preg_match( |
| 216 | - '/<' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 216 | + '/<'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 217 | 217 | $htmlArray[$x] |
| 218 | 218 | ) || preg_match( |
| 219 | - '/<' . $structureBoxLikeElements . '(.*) \/>/Usi', |
|
| 219 | + '/<'.$structureBoxLikeElements.'(.*) \/>/Usi', |
|
| 220 | 220 | $htmlArray[$x] |
| 221 | 221 | ) || # one element before is a element that has a line break after |
| 222 | 222 | preg_match( |
| 223 | - '/<\/' . $structureBoxLikeElements . '(.*)>/Usi', |
|
| 223 | + '/<\/'.$structureBoxLikeElements.'(.*)>/Usi', |
|
| 224 | 224 | $htmlArray[$x - 1] |
| 225 | 225 | ) || substr( |
| 226 | 226 | $htmlArray[$x - 1], |
| 227 | 227 | 0, |
| 228 | 228 | 4 |
| 229 | - ) == '<!--' || preg_match('/<' . $structureBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 229 | + ) == '<!--' || preg_match('/<'.$structureBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 230 | 230 | ) { |
| 231 | 231 | $newline = true; |
| 232 | 232 | } elseif ($this->formatType == 3 && ( // aestetic line break |
| 233 | 233 | # this element has a line break before itself |
| 234 | 234 | preg_match( |
| 235 | - '/<' . $esteticBoxLikeElements . '(.*)>/Usi', |
|
| 235 | + '/<'.$esteticBoxLikeElements.'(.*)>/Usi', |
|
| 236 | 236 | $htmlArray[$x] |
| 237 | 237 | ) || preg_match( |
| 238 | - '/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', |
|
| 238 | + '/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', |
|
| 239 | 239 | $htmlArray[$x] |
| 240 | 240 | ) || # one element before is a element that has a line break after |
| 241 | - preg_match('/<\/' . $esteticBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 241 | + preg_match('/<\/'.$esteticBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 242 | 242 | $htmlArray[$x - 1], |
| 243 | 243 | 0, |
| 244 | 244 | 4 |
| 245 | - ) == '<!--' || preg_match('/<' . $esteticBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 245 | + ) == '<!--' || preg_match('/<'.$esteticBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 246 | 246 | ) { |
| 247 | 247 | $newline = true; |
| 248 | 248 | } elseif ($this->formatType >= 4 && ( // logical line break |
| 249 | 249 | # this element has a line break before itself |
| 250 | 250 | preg_match( |
| 251 | - '/<' . $allBoxLikeElements . '(.*)>/Usi', |
|
| 251 | + '/<'.$allBoxLikeElements.'(.*)>/Usi', |
|
| 252 | 252 | $htmlArray[$x] |
| 253 | 253 | ) || preg_match( |
| 254 | - '/<' . $allBoxLikeElements . '(.*) \/>/Usi', |
|
| 254 | + '/<'.$allBoxLikeElements.'(.*) \/>/Usi', |
|
| 255 | 255 | $htmlArray[$x] |
| 256 | 256 | ) || # one element before is a element that has a line break after |
| 257 | - preg_match('/<\/' . $allBoxLikeElements . '(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 257 | + preg_match('/<\/'.$allBoxLikeElements.'(.*)>/Usi', $htmlArray[$x - 1]) || substr( |
|
| 258 | 258 | $htmlArray[$x - 1], |
| 259 | 259 | 0, |
| 260 | 260 | 4 |
| 261 | - ) == '<!--' || preg_match('/<' . $allBoxLikeElements . '(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 261 | + ) == '<!--' || preg_match('/<'.$allBoxLikeElements.'(.*) \/>/Usi', $htmlArray[$x - 1])) |
|
| 262 | 262 | ) { |
| 263 | 263 | $newline = true; |
| 264 | 264 | } |
@@ -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 | |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | 'textarea', |
| 470 | 470 | 'pre' |
| 471 | 471 | ]; // eventuell auch: span, script, style |
| 472 | - $peaces = preg_split('#(<(' . implode('|', $splitArray) . ').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 472 | + $peaces = preg_split('#(<('.implode('|', $splitArray).').*>.*</\2>)#Uis', $html, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 473 | 473 | $html = ""; |
| 474 | 474 | for ($i = 0; $i < count($peaces); $i++) { |
| 475 | 475 | if (($i + 1) % 3 == 0) { |
@@ -523,8 +523,8 @@ discard block |
||
| 523 | 523 | public function includeHeaderComment(&$html) |
| 524 | 524 | { |
| 525 | 525 | if (!empty($this->headerComment)) { |
| 526 | - $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function ($matches) { |
|
| 527 | - return trim($matches[0] . $this->newline . $this->tab . $this->tab . '<!-- ' . $this->headerComment . '-->'); |
|
| 526 | + $html = preg_replace_callback('/<meta http-equiv(.*)>/Usi', function($matches) { |
|
| 527 | + return trim($matches[0].$this->newline.$this->tab.$this->tab.'<!-- '.$this->headerComment.'-->'); |
|
| 528 | 528 | }, $html, 1); |
| 529 | 529 | } |
| 530 | 530 | } |