/**
  * _getFiles()
  *
  * @return array Array of files to load
  */
 protected function _getFiles()
 {
     // require_once 'Zend/Loader.php';
     $paths = Zend_Loader::explodeIncludePath();
     // used for checking similarly named files
     $relativeItems = array();
     $files = array();
     $isZendTraversed = false;
     foreach ($paths as $path) {
         // default patterns to use
         $filterDenyDirectoryPattern = '.*(/|\\\\).svn';
         $filterAcceptFilePattern = '.*(?:Manifest|Provider)\\.php$';
         if (!file_exists($path) || $path[0] == '.') {
             continue;
         }
         $realIncludePath = realpath($path);
         // ensure that we only traverse a single version of Zend Framework on all include paths
         if (file_exists($realIncludePath . '/Zend/Tool/Framework/Loader/IncludePathLoader.php')) {
             if ($isZendTraversed === false) {
                 $isZendTraversed = true;
             } else {
                 // use the deny directory pattern that includes the path to 'Zend', it will not be accepted
                 $filterDenyDirectoryPattern = '.*((/|\\\\).svn|' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR) . 'Zend)';
             }
         }
         // create recursive directory iterator
         $rdi = new RecursiveDirectoryIterator($path);
         // pass in the RecursiveDirectoryIterator & the patterns
         $filter = new Zend_Tool_Framework_Loader_IncludePathLoader_RecursiveFilterIterator($rdi, $filterDenyDirectoryPattern, $filterAcceptFilePattern);
         // build the rii with the filter
         $iterator = new RecursiveIteratorIterator($filter);
         // iterate over the accepted items
         foreach ($iterator as $item) {
             $file = (string) $item;
             if ($this->_fileIsBlacklisted($file)) {
                 continue;
             }
             // ensure that the same named file from separate include_paths is not loaded
             $relativeItem = preg_replace('#^' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR, '#') . '#', '', $item->getRealPath());
             // no links allowed here for now
             if ($item->isLink()) {
                 continue;
             }
             // no items that are relavitely the same are allowed
             if (in_array($relativeItem, $relativeItems)) {
                 continue;
             }
             $relativeItems[] = $relativeItem;
             $files[] = $item->getRealPath();
         }
     }
     return $files;
 }
 /**
  * _getZfPath()
  *
  * @return string|false
  */
 protected function _getZfPath()
 {
     foreach (Zend_Loader::explodeIncludePath() as $includePath) {
         if (!file_exists($includePath) || $includePath[0] == '.') {
             continue;
         }
         if (realpath($checkedPath = rtrim($includePath, '\\/') . '/Zend/Loader.php') !== false && file_exists($checkedPath)) {
             return dirname($checkedPath);
         }
     }
     return false;
 }
 /**
  * _getZfPath()
  *
  * @return string|false
  */
 protected function _getZfPath()
 {
     require_once PHP_LIBRARY_PATH . 'Zend/Loader.php';
     foreach (Zend_Loader::explodeIncludePath() as $includePath) {
         if (!file_exists($includePath) || $includePath[0] == '.') {
             continue;
         }
         if (cleanPath($checkedPath = rtrim($includePath, '\\/') . '/Zend/Loader.php') !== false && file_exists($checkedPath)) {
             return dirname($checkedPath);
         }
     }
     return false;
 }
Beispiel #4
0
 /**
  * Find realpath of file based on include_path
  *
  * @param  string $fileName
  * @return string
  */
 public static function findRealpathInIncludePath($fileName)
 {
     require_once 'Zend/Loader.php';
     $includePaths = Zend_Loader::explodeIncludePath();
     while (count($includePaths) > 0) {
         $filePath = array_shift($includePaths) . DIRECTORY_SEPARATOR . $fileName;
         if (($foundRealpath = realpath($filePath)) !== false) {
             break;
         }
     }
     return $foundRealpath;
 }
Beispiel #5
0
 /**
  * @group ZF-7271
  */
 public function testExplodeIncludePathProperlyIdentifiesStreamSchemes()
 {
     if (PATH_SEPARATOR != ':') {
         $this->markTestSkipped();
     }
     $path = 'phar://zlt.phar:/var/www:.:filter://[a-z]:glob://*';
     $paths = Zend_Loader::explodeIncludePath($path);
     $this->assertSame(array('phar://zlt.phar', '/var/www', '.', 'filter://[a-z]', 'glob://*'), $paths);
 }
Beispiel #6
0
 /**
  * Add existing include path directories to subdirectory (if not absolute)
  *
  * @staticvar string $includePaths Array containing exploded and checked include path
  * @param string $path
  * @return array Can be empty if none of the options exist
  */
 public static function getAbsolutePaths($path)
 {
     static $includePaths;
     if ($path) {
         // Try to see if the path is an absolute path. Some exotic absolute paths can fail this test,
         // but it is more error prone to test for them here than to loop through them afterwards.
         if (self::isAbsolutePath($path)) {
             if ($real = realpath($path)) {
                 return array($real);
             } else {
                 return array();
             }
         }
     }
     if (!is_array($includePaths)) {
         // Make sure the include path are loaded
         foreach (\Zend_Loader::explodeIncludePath() as $include) {
             // Current path will be checked, for each file
             // but check the other paths for exiistence
             if ('.' != $include && ($real = realpath($include))) {
                 $includePaths[] = $real . DIRECTORY_SEPARATOR;
             }
         }
     }
     // Check path name
     $results = array();
     if ($real = realpath($path)) {
         $results[] = $real;
     }
     // Check simple concatenation
     foreach ($includePaths as $include) {
         if ($real = realpath($include . $path)) {
             $results[] = $real;
         }
     }
     // Reverse the result as that is the order this loader handles the directories
     return array_reverse($results);
 }
Beispiel #7
0
 /**
  * Initialize the _includeDirs variable
  */
 protected function _loadIncludePath()
 {
     $dirs = \Zend_Loader::explodeIncludePath();
     foreach ($dirs as $dir) {
         if ('.' != $dir && is_dir($dir)) {
             $this->_includeDirs[] = realpath($dir) . DIRECTORY_SEPARATOR;
         }
     }
 }