| @@ 217-244 (lines=28) @@ | ||
| 214 | ); |
|
| 215 | } |
|
| 216 | ||
| 217 | protected function _removeScriptCB($m) |
|
| 218 | {
|
|
| 219 | $openScript = "<script{$m[2]}";
|
|
| 220 | $js = $m[3]; |
|
| 221 | ||
| 222 | // whitespace surrounding? preserve at least one space |
|
| 223 | $ws1 = ($m[1] === '') ? '' : ' '; |
|
| 224 | $ws2 = ($m[4] === '') ? '' : ' '; |
|
| 225 | ||
| 226 | // remove HTML comments (and ending "//" if present) |
|
| 227 | if ($this->_jsCleanComments) {
|
|
| 228 | $js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
|
|
| 229 | } |
|
| 230 | ||
| 231 | // remove CDATA section markers |
|
| 232 | $js = $this->_removeCdata($js); |
|
| 233 | ||
| 234 | // minify |
|
| 235 | $minifier = $this->_jsMinifier |
|
| 236 | ? $this->_jsMinifier |
|
| 237 | : 'trim'; |
|
| 238 | $js = call_user_func($minifier, $js); |
|
| 239 | ||
| 240 | return $this->_reservePlace($this->_needsCdata($js) |
|
| 241 | ? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
|
|
| 242 | : "{$ws1}{$openScript}{$js}</script>{$ws2}"
|
|
| 243 | ); |
|
| 244 | } |
|
| 245 | ||
| 246 | protected function _removeCdata($str) |
|
| 247 | {
|
|
| @@ 230-255 (lines=26) @@ | ||
| 227 | ); |
|
| 228 | } |
|
| 229 | ||
| 230 | protected function _removeScriptCB($m) |
|
| 231 | { |
|
| 232 | $openScript = $m[2]; |
|
| 233 | $js = $m[3]; |
|
| 234 | ||
| 235 | // whitespace surrounding? preserve at least one space |
|
| 236 | $ws1 = ($m[1] === '') ? '' : ' '; |
|
| 237 | $ws2 = ($m[4] === '') ? '' : ' '; |
|
| 238 | ||
| 239 | // remove HTML comments (and ending "//" if present) |
|
| 240 | $js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js); |
|
| 241 | ||
| 242 | // remove CDATA section markers |
|
| 243 | $js = $this->_removeCdata($js); |
|
| 244 | ||
| 245 | // minify |
|
| 246 | $minifier = $this->_jsMinifier |
|
| 247 | ? $this->_jsMinifier |
|
| 248 | : 'trim'; |
|
| 249 | $js = call_user_func($minifier, $js); |
|
| 250 | ||
| 251 | return $this->_reservePlace($this->_needsCdata($js) |
|
| 252 | ? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}" |
|
| 253 | : "{$ws1}{$openScript}{$js}</script>{$ws2}" |
|
| 254 | ); |
|
| 255 | } |
|
| 256 | ||
| 257 | protected function _removeCdata($str) |
|
| 258 | { |
|