예제 #1
0
파일: Document.php 프로젝트: phmlabs/base
 public function getExternalDependencies($fileExtensions = array('css', 'js'), Uri $uri = null)
 {
     if (!is_array($fileExtensions)) {
         return false;
     }
     $extensions = implode('|', $fileExtensions);
     $pattern = '/[^\'](?:<link|<script).*(?:href|src)=["\']([\\S]+\\.(?:' . $extensions . ')+[?\\S]*)[\'"][^\']/iU';
     $matches = array();
     preg_match_all($pattern, $this->content, $matches);
     $cleanFiles = array();
     $files = $matches[1];
     if (!is_null($uri)) {
         $uri = htmlspecialchars_decode($uri);
         $uri = new Uri($uri);
         $cleanFiles = array();
         foreach ($files as $file) {
             $cleanFiles[] = $uri->concatUri($file);
         }
     } else {
         foreach ($files as $file) {
             $cleanFiles[] = new Uri($file);
         }
     }
     return $cleanFiles;
 }