Created
January 18, 2010 19:25
-
-
Save ericboehs/280281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $file = 'test.tpl'; | |
| preg_match_all('/(?!{compress name=.*})[^}{]+?(?={\/compress})/',file_get_contents($file), $compress_blocks); | |
| $compress_blocks = array_map('trim', $compress_blocks[0]); | |
| foreach($compress_blocks as $compress_block){ | |
| $compress_block = '<?xml version="1.0" encoding="ISO-8859-1"?>'.'<xml>'.$compress_block."</xml>"; | |
| $xmlDoc = new DOMDocument(); | |
| $xmlDoc->loadXML($compress_block); | |
| $x = $xmlDoc->documentElement; | |
| foreach($x->childNodes as $item){ | |
| if($item->nodeName == "link") | |
| $css_files[$item->getAttribute('media')][] = $item->getAttribute('href'); | |
| if($item->nodeName == "script") | |
| $js_files[] = $item->getAttribute('src'); | |
| } | |
| unset($xmlDoc); | |
| } | |
| print_r ($css_files); | |
| print_r ($js_files); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment