/**
  * Tries to open or include various files and put their contents together in
  * an array
  *
  * @param   bool  $allowIncludes    (Optional) Whether to allow php includes
  *                                  of files
  * @param   array $includeSuffixes  (Optional) if includes are allowed a
  *                                  suffix of file endings to allow (basically
  *                                  extensions like .php)
  * @param   array $dontInclude      (Optional) An array of filenames that
  *                                  should not be included
  * @return  array
  */
 protected function _collateFileContents($allowIncludes = false, $includeSuffixes = array(), $dontInclude = array())
 {
     // get old contents
     $oldFileContents = $this->getFileContents();
     $fileContents = array();
     foreach ($this->getFiles() as $file) {
         if (array_key_exists($file, $oldFileContents)) {
             $fileContents[$file] = $oldFileContents[$file];
             continue;
         }
         $assetPath = $this->getAssetPath($file);
         // break off any query string in the name
         $fileParts = explode('?', $assetPath);
         $fileName = $fileParts[0];
         try {
             $filePath = sfCombineUtility::getFilePath($fileName);
             if (!$filePath) {
                 throw new Exception($fileName . ' does not exist');
             }
             if (!is_readable($filePath)) {
                 throw new Exception($filePath . ' is not readable');
             }
             $realPath = realpath($filePath);
             // realpath breaks symlinked assets
             $normalizedPath = sfCombineUtility::normalizePath($filePath);
             if (strpos($realPath, sfConfig::get('sf_web_dir')) !== 0 && strpos($normalizedPath, sfConfig::get('sf_web_dir')) !== 0) {
                 throw new Exception($filePath . ' is not in the web directory');
             }
             $includeFile = false;
             if ($allowIncludes) {
                 // check to see if we are to include this file or get contents
                 if (is_array($includeSuffixes)) {
                     foreach ($includeSuffixes as $suffix) {
                         if (strlen($filePath) > strlen($suffix) && substr($filePath, strlen($filePath) - strlen($suffix)) == $suffix) {
                             $includeFile = true;
                             break;
                         }
                     }
                 }
                 // check if file is blacklisted from being included
                 if (is_array($dontInclude)) {
                     $nonAssetParts = explode('?', $file);
                     $nonAssetName = $nonAssetParts[0];
                     foreach ($dontInclude as $name) {
                         if ($name == $fileName || $name == $assetPath || $name == $file || $name == $nonAssetName) {
                             $includeFile = false;
                             break;
                         }
                     }
                 }
             }
             // end if
             if ($includeFile) {
                 // set gets
                 $gets = array();
                 if (isset($fileParts[1])) {
                     parse_str($fileParts[1], $gets);
                 }
                 $contents = self::getIncludeFileContents($filePath, true, $gets);
             } else {
                 $contents = @file_get_contents($filePath);
                 if ($contents === false) {
                     throw new Exception('Could not open ' . $filePath);
                 }
             }
             $fileContents[$file] = $contents;
         } catch (Exception $e) {
             sfContext::getInstance()->getLogger()->err('sfCombine exception: ' . $e->getMessage());
         }
     }
     $this->setFileContents($fileContents);
     return $this->getFileContents();
 }