| 29 | | $ldr->setClassFileEndings(array('.php')); |
|---|
| 30 | | $ldr->setIgnoreHiddenFiles(true); |
|---|
| 31 | | $ldr->setIgnoreSVN(true); |
|---|
| 32 | | } |
|---|
| 33 | | |
|---|
| 34 | | /* load the class or trigger some fatal error on failure */ |
|---|
| 35 | | if(!$ldr->loadClass($class_name)) { |
|---|
| 36 | | trigger_error("SmartLoader: Cannot load class '".$class_name."'", E_USER_ERROR); |
|---|
| 37 | | } |
|---|
| 38 | | } |
|---|
| | 29 | $ldr->setClassFileEndings(array('.php')); |
|---|
| | 30 | $ldr->setIgnoreHiddenFiles(true); |
|---|
| | 31 | $ldr->setIgnoreSVN(true); |
|---|
| | 32 | } |
|---|
| | 33 | |
|---|
| | 34 | /* load the class or trigger some fatal error on failure */ |
|---|
| | 35 | if(!$ldr->loadClass($class_name)) { |
|---|
| | 36 | trigger_error("SmartLoader: Cannot load class '".$class_name."'", E_USER_ERROR); |
|---|
| | 37 | } |
|---|
| | 38 | } |
|---|
| 60 | | } |
|---|
| 61 | | |
|---|
| 62 | | |
|---|
| 63 | | /** |
|---|
| 64 | | * SmartLoader Class |
|---|
| 65 | | * |
|---|
| 66 | | * Singleton. Manages class/interface retrieval, caching and inclusion. |
|---|
| 67 | | * |
|---|
| 68 | | * @package SmartLoader |
|---|
| 69 | | * @author Maarten Manders (mandersm@student.ethz.ch) |
|---|
| 70 | | * @example index.php |
|---|
| 71 | | * @see SmartLoader::instance() |
|---|
| 72 | | * @see SmartLoader::addDir() |
|---|
| 73 | | * @see SmartLoader::loadClass() |
|---|
| 74 | | */ |
|---|
| 75 | | class SmartLoader |
|---|
| 76 | | { |
|---|
| 77 | | /** |
|---|
| 78 | | * Class Directories |
|---|
| 79 | | * |
|---|
| 80 | | * Holds the directories SmartLoader scans for class/interface definitions |
|---|
| 81 | | * |
|---|
| 82 | | * @var array |
|---|
| 83 | | * @access private |
|---|
| 84 | | */ |
|---|
| 85 | | private $classDirectories = array(); |
|---|
| 86 | | |
|---|
| 87 | | /** |
|---|
| 88 | | * Cache File Path |
|---|
| 89 | | * |
|---|
| 90 | | * Holds the filename of the generated cache file. |
|---|
| 91 | | * |
|---|
| 92 | | * @var string |
|---|
| 93 | | * @access private |
|---|
| 94 | | */ |
|---|
| 95 | | private $cacheFilename = 'smartloader_cache.php'; |
|---|
| 96 | | |
|---|
| 97 | | /** |
|---|
| 98 | | * Class Index |
|---|
| 99 | | * |
|---|
| 100 | | * Holds an associative array (class name => class file) when scanning. |
|---|
| 101 | | * |
|---|
| 102 | | * @var array |
|---|
| 103 | | * @access private |
|---|
| 104 | | */ |
|---|
| 105 | | private $classIndex = array(); |
|---|
| 106 | | |
|---|
| 107 | | /** |
|---|
| 108 | | * Class File Endings |
|---|
| 109 | | * |
|---|
| 110 | | * Files with these endings will be parsed by the class/interface scanner. |
|---|
| 111 | | * |
|---|
| 112 | | * @var array |
|---|
| 113 | | * @access private |
|---|
| 114 | | */ |
|---|
| 115 | | private $classFileEndings = array(); |
|---|
| 116 | | |
|---|
| 117 | | /** |
|---|
| 118 | | * Follow SymLinks |
|---|
| 119 | | * |
|---|
| 120 | | * Should SmartLoader follow SymLinks when searching class dirs? |
|---|
| 121 | | * |
|---|
| 122 | | * @var boolean |
|---|
| 123 | | * @access private |
|---|
| 124 | | */ |
|---|
| 125 | | private $followSymlinks = true; |
|---|
| 126 | | |
|---|
| 127 | | /** |
|---|
| 128 | | * Ignore hidden files |
|---|
| 129 | | * |
|---|
| 130 | | * Should SmartLoader ignore hidden files? |
|---|
| 131 | | * |
|---|
| 132 | | * @access private |
|---|
| 133 | | */ |
|---|
| 134 | | private $ignoreHiddenFiles = false; |
|---|
| | 60 | } |
|---|
| | 61 | |
|---|
| | 62 | |
|---|
| | 63 | /** |
|---|
| | 64 | * SmartLoader Class |
|---|
| | 65 | * |
|---|
| | 66 | * Singleton. Manages class/interface retrieval, caching and inclusion. |
|---|
| | 67 | * |
|---|
| | 68 | * @package SmartLoader |
|---|
| | 69 | * @author Maarten Manders (mandersm@student.ethz.ch) |
|---|
| | 70 | * @example index.php |
|---|
| | 71 | * @see SmartLoader::instance() |
|---|
| | 72 | * @see SmartLoader::addDir() |
|---|
| | 73 | * @see SmartLoader::loadClass() |
|---|
| | 74 | */ |
|---|
| | 75 | class SmartLoader |
|---|
| | 76 | { |
|---|
| | 77 | /** |
|---|
| | 78 | * Class Directories |
|---|
| | 79 | * |
|---|
| | 80 | * Holds the directories SmartLoader scans for class/interface definitions |
|---|
| | 81 | * |
|---|
| | 82 | * @var array |
|---|
| | 83 | * @access private |
|---|
| | 84 | */ |
|---|
| | 85 | private $classDirectories = array(); |
|---|
| | 86 | |
|---|
| | 87 | /** |
|---|
| | 88 | * Cache File Path |
|---|
| | 89 | * |
|---|
| | 90 | * Holds the filename of the generated cache file. |
|---|
| | 91 | * |
|---|
| | 92 | * @var string |
|---|
| | 93 | * @access private |
|---|
| | 94 | */ |
|---|
| | 95 | private $cacheFilename = 'smartloader_cache.php'; |
|---|
| | 96 | |
|---|
| | 97 | /** |
|---|
| | 98 | * Class Index |
|---|
| | 99 | * |
|---|
| | 100 | * Holds an associative array (class name => class file) when scanning. |
|---|
| | 101 | * |
|---|
| | 102 | * @var array |
|---|
| | 103 | * @access private |
|---|
| | 104 | */ |
|---|
| | 105 | private $classIndex = array(); |
|---|
| | 106 | |
|---|
| | 107 | /** |
|---|
| | 108 | * Class File Endings |
|---|
| | 109 | * |
|---|
| | 110 | * Files with these endings will be parsed by the class/interface scanner. |
|---|
| | 111 | * |
|---|
| | 112 | * @var array |
|---|
| | 113 | * @access private |
|---|
| | 114 | */ |
|---|
| | 115 | private $classFileEndings = array(); |
|---|
| | 116 | |
|---|
| | 117 | /** |
|---|
| | 118 | * Follow SymLinks |
|---|
| | 119 | * |
|---|
| | 120 | * Should SmartLoader follow SymLinks when searching class dirs? |
|---|
| | 121 | * |
|---|
| | 122 | * @var boolean |
|---|
| | 123 | * @access private |
|---|
| | 124 | */ |
|---|
| | 125 | private $followSymlinks = true; |
|---|
| | 126 | |
|---|
| | 127 | /** |
|---|
| | 128 | * Ignore hidden files |
|---|
| | 129 | * |
|---|
| | 130 | * Should SmartLoader ignore hidden files? |
|---|
| | 131 | * |
|---|
| | 132 | * @access private |
|---|
| | 133 | */ |
|---|
| | 134 | private $ignoreHiddenFiles = false; |
|---|
| 179 | | /** |
|---|
| 180 | | * Set Cache File Path |
|---|
| 181 | | * |
|---|
| 182 | | * Define a path to store the cache file. Make sure PHP has permission read/write on it. |
|---|
| 183 | | * |
|---|
| 184 | | * @access public |
|---|
| 185 | | * @param string string Cache File Path |
|---|
| 186 | | */ |
|---|
| 187 | | public function setCacheFilename($cacheFilename) { |
|---|
| 188 | | $this->cacheFilename = $cacheFilename; |
|---|
| 189 | | } |
|---|
| 190 | | |
|---|
| 191 | | /** |
|---|
| 192 | | * Set Class File Endings |
|---|
| 193 | | * |
|---|
| 194 | | * Define which file endings will be considered by the class/interface scanner |
|---|
| 195 | | * An empty array will let the scanner parse any file type. |
|---|
| 196 | | * |
|---|
| 197 | | * @access public |
|---|
| 198 | | * @param array Endings |
|---|
| 199 | | */ |
|---|
| 200 | | public function setClassFileEndings($classFileEndings) { |
|---|
| 201 | | $this->classFileEndings = $classFileEndings; |
|---|
| 202 | | } |
|---|
| 203 | | |
|---|
| 204 | | /** |
|---|
| 205 | | * Set Follow Symlinks Flag |
|---|
| 206 | | * |
|---|
| 207 | | * Define whether SmartLoader should follow symlinks in when searching the class directory |
|---|
| 208 | | * |
|---|
| 209 | | * @access public |
|---|
| 210 | | * @param boolean follow symlinks |
|---|
| 211 | | */ |
|---|
| 212 | | public function setfollowSymlinks($value) { |
|---|
| 213 | | $this->followSymlinks = $value; |
|---|
| 214 | | } |
|---|
| 215 | | |
|---|
| 216 | | /** |
|---|
| 217 | | * Set ignore hidden files |
|---|
| 218 | | * |
|---|
| 219 | | * Define whether SmartLoader should ignore hidden files |
|---|
| 220 | | * |
|---|
| 221 | | * @access public |
|---|
| 222 | | * @param boolean value, true to ignore |
|---|
| 223 | | */ |
|---|
| 224 | | public function setIgnoreHiddenFiles($value) { |
|---|
| 225 | | $this->ignoreHiddenFiles = $value; |
|---|
| 226 | | } |
|---|
| | 179 | /** |
|---|
| | 180 | * Set Cache File Path |
|---|
| | 181 | * |
|---|
| | 182 | * Define a path to store the cache file. Make sure PHP has permission read/write on it. |
|---|
| | 183 | * |
|---|
| | 184 | * @access public |
|---|
| | 185 | * @param string string Cache File Path |
|---|
| | 186 | */ |
|---|
| | 187 | public function setCacheFilename($cacheFilename) { |
|---|
| | 188 | $this->cacheFilename = $cacheFilename; |
|---|
| | 189 | } |
|---|
| | 190 | |
|---|
| | 191 | /** |
|---|
| | 192 | * Set Class File Endings |
|---|
| | 193 | * |
|---|
| | 194 | * Define which file endings will be considered by the class/interface scanner |
|---|
| | 195 | * An empty array will let the scanner parse any file type. |
|---|
| | 196 | * |
|---|
| | 197 | * @access public |
|---|
| | 198 | * @param array Endings |
|---|
| | 199 | */ |
|---|
| | 200 | public function setClassFileEndings($classFileEndings) { |
|---|
| | 201 | $this->classFileEndings = $classFileEndings; |
|---|
| | 202 | } |
|---|
| | 203 | |
|---|
| | 204 | /** |
|---|
| | 205 | * Set Follow Symlinks Flag |
|---|
| | 206 | * |
|---|
| | 207 | * Define whether SmartLoader should follow symlinks in when searching the class directory |
|---|
| | 208 | * |
|---|
| | 209 | * @access public |
|---|
| | 210 | * @param boolean follow symlinks |
|---|
| | 211 | */ |
|---|
| | 212 | public function setfollowSymlinks($value) { |
|---|
| | 213 | $this->followSymlinks = $value; |
|---|
| | 214 | } |
|---|
| | 215 | |
|---|
| | 216 | /** |
|---|
| | 217 | * Set ignore hidden files |
|---|
| | 218 | * |
|---|
| | 219 | * Define whether SmartLoader should ignore hidden files |
|---|
| | 220 | * |
|---|
| | 221 | * @access public |
|---|
| | 222 | * @param boolean value, true to ignore |
|---|
| | 223 | */ |
|---|
| | 224 | public function setIgnoreHiddenFiles($value) { |
|---|
| | 225 | $this->ignoreHiddenFiles = $value; |
|---|
| | 226 | } |
|---|
| 234 | | /** |
|---|
| 235 | | * Add a directory to retrieve classes/interfaces from |
|---|
| 236 | | * |
|---|
| 237 | | * This function adds a directory to retrieve class/interface definitions from. |
|---|
| 238 | | * |
|---|
| 239 | | * @access public |
|---|
| 240 | | * @param string $directory_path |
|---|
| 241 | | */ |
|---|
| 242 | | public function addDir($directory_path) { |
|---|
| 243 | | // add trailing slash |
|---|
| 244 | | if(substr($directory_path, -1) != '/') { |
|---|
| 245 | | $directory_path .= '/'; |
|---|
| 246 | | } |
|---|
| 247 | | if(!in_array($directory_path, $this->classDirectories)) { |
|---|
| 248 | | $this->classDirectories[] = $directory_path; |
|---|
| 249 | | } |
|---|
| 250 | | } |
|---|
| 251 | | |
|---|
| 252 | | /** |
|---|
| 253 | | * Load a Class |
|---|
| 254 | | * |
|---|
| 255 | | * Loads a class by its name |
|---|
| 256 | | * - If the matching class definition file can't be found in the cache, |
|---|
| 257 | | * it will try once again with $retry = true. |
|---|
| 258 | | * - When retrying, the cached index is invalidated, regenerated and re-included. |
|---|
| 259 | | * |
|---|
| 260 | | * @access public |
|---|
| 261 | | * @param string $class_name |
|---|
| 262 | | * @param boolean $retry used for recursion |
|---|
| 263 | | * @return boolean Success |
|---|
| 264 | | */ |
|---|
| 265 | | public function loadClass($class_name, $retry = false) { |
|---|
| 266 | | /* Is the class already defined? (can be omitted in combination with __autoload) */ |
|---|
| 267 | | if(class_exists($class_name)) { |
|---|
| 268 | | return true; |
|---|
| 269 | | } |
|---|
| 270 | | |
|---|
| 271 | | /* Is our cache outdated or not available? Recreate it! */ |
|---|
| 272 | | if($retry || !is_readable($this->cacheFilename)) { |
|---|
| | 234 | /** |
|---|
| | 235 | * Add a directory to retrieve classes/interfaces from |
|---|
| | 236 | * |
|---|
| | 237 | * This function adds a directory to retrieve class/interface definitions from. |
|---|
| | 238 | * |
|---|
| | 239 | * @access public |
|---|
| | 240 | * @param string $directory_path |
|---|
| | 241 | */ |
|---|
| | 242 | public function addDir($directory_path) { |
|---|
| | 243 | // add trailing slash |
|---|
| | 244 | if(substr($directory_path, -1) != '/') { |
|---|
| | 245 | $directory_path .= '/'; |
|---|
| | 246 | } |
|---|
| | 247 | if(!in_array($directory_path, $this->classDirectories)) { |
|---|
| | 248 | $this->classDirectories[] = $directory_path; |
|---|
| | 249 | } |
|---|
| | 250 | } |
|---|
| | 251 | |
|---|
| | 252 | /** |
|---|
| | 253 | * Load a Class |
|---|
| | 254 | * |
|---|
| | 255 | * Loads a class by its name |
|---|
| | 256 | * - If the matching class definition file can't be found in the cache, |
|---|
| | 257 | * it will try once again with $retry = true. |
|---|
| | 258 | * - When retrying, the cached index is invalidated, regenerated and re-included. |
|---|
| | 259 | * |
|---|
| | 260 | * @access public |
|---|
| | 261 | * @param string $class_name |
|---|
| | 262 | * @param boolean $retry used for recursion |
|---|
| | 263 | * @return boolean Success |
|---|
| | 264 | */ |
|---|
| | 265 | public function loadClass($class_name, $retry = false) { |
|---|
| | 266 | /* Is the class already defined? (can be omitted in combination with __autoload) */ |
|---|
| | 267 | if(class_exists($class_name)) { |
|---|
| | 268 | return true; |
|---|
| | 269 | } |
|---|
| | 270 | |
|---|
| | 271 | /* Is our cache outdated or not available? Recreate it! */ |
|---|
| | 272 | if($retry || !is_readable($this->cacheFilename)) { |
|---|
| 280 | | if(!$this->classes) { |
|---|
| 281 | | trigger_error("SmartLoader: Cannot include cache file from '".$this->cacheFilename."'", E_USER_ERROR); |
|---|
| 282 | | } |
|---|
| 283 | | |
|---|
| 284 | | /* Include requested file. Return on success */ |
|---|
| 285 | | if(isset($this->classes[$class_name]) && is_readable($this->classes[$class_name])) { |
|---|
| 286 | | if(include($this->classes[$class_name])) { |
|---|
| 287 | | return true; |
|---|
| 288 | | } |
|---|
| 289 | | } |
|---|
| 290 | | |
|---|
| 291 | | /* On failure retry recursively, but only once. */ |
|---|
| 292 | | if($retry) { |
|---|
| 293 | | return false; |
|---|
| 294 | | } else { |
|---|
| 295 | | return $this->loadClass($class_name, true); |
|---|
| 296 | | } |
|---|
| 297 | | } |
|---|
| | 280 | if(!$this->classes) { |
|---|
| | 281 | trigger_error("SmartLoader: Cannot include cache file from '".$this->cacheFilename."'", E_USER_ERROR); |
|---|
| | 282 | } |
|---|
| | 283 | |
|---|
| | 284 | /* Include requested file. Return on success */ |
|---|
| | 285 | if(isset($this->classes[$class_name]) && is_readable($this->classes[$class_name])) { |
|---|
| | 286 | if(include($this->classes[$class_name])) { |
|---|
| | 287 | return true; |
|---|
| | 288 | } |
|---|
| | 289 | } |
|---|
| | 290 | |
|---|
| | 291 | /* On failure retry recursively, but only once. */ |
|---|
| | 292 | if($retry) { |
|---|
| | 293 | return false; |
|---|
| | 294 | } else { |
|---|
| | 295 | return $this->loadClass($class_name, true); |
|---|
| | 296 | } |
|---|
| | 297 | } |
|---|
| 306 | | /** |
|---|
| 307 | | * Create Cache |
|---|
| 308 | | * |
|---|
| 309 | | * - Scans the class dirs for class/interface definitions and |
|---|
| 310 | | * creates an associative array (class name => class file) |
|---|
| 311 | | * - Generates the array in PHP code and saves it as cache file |
|---|
| 312 | | * |
|---|
| 313 | | * @access private |
|---|
| 314 | | * @param param_type $param_name |
|---|
| 315 | | */ |
|---|
| 316 | | public function createCache() { |
|---|
| 317 | | /* Create class list */ |
|---|
| 318 | | foreach($this->classDirectories as $dir) { |
|---|
| 319 | | $this->parseDir($dir); |
|---|
| 320 | | } |
|---|
| 321 | | |
|---|
| 322 | | /* Generate php cache file */ |
|---|
| 323 | | $cache_content = "<?php\n\t// this is an automatically generated cache file.\n" |
|---|
| 324 | | ."\t// it serves as 'class name' / 'class file' association index for the SmartLoader\n"; |
|---|
| 325 | | foreach($this->classIndex as $class_name => $class_file) { |
|---|
| 326 | | $cache_content .= "\t\$classes['".$class_name."'] = '".$class_file."';\n"; |
|---|
| 327 | | } |
|---|
| 328 | | $cache_content .= " return \$classes; ?>"; |
|---|
| 329 | | if($cacheFilename_handle = fopen($this->cacheFilename, "w+")) { |
|---|
| 330 | | fwrite($cacheFilename_handle, $cache_content); |
|---|
| 331 | | /* Allow ftp users to access/modify/delete cache file, suppress chmod errors here */ |
|---|
| 332 | | @chmod($this->cacheFilename, 0664); |
|---|
| 333 | | } |
|---|
| 334 | | } |
|---|
| 335 | | |
|---|
| 336 | | /** |
|---|
| 337 | | * Parse Directory |
|---|
| 338 | | * |
|---|
| 339 | | * Parses a directory for class/interface definitions. Saves found definitions |
|---|
| 340 | | * in $classIndex. Needless to say: Mind recursion cycles when using symlinks. |
|---|
| 341 | | * TODO: Clean up this method; use SPL, if suitable. |
|---|
| 342 | | * |
|---|
| 343 | | * @access private |
|---|
| 344 | | * @param string $directory_path |
|---|
| 345 | | * @return boolean Success |
|---|
| 346 | | */ |
|---|
| 347 | | private function parseDir($directory_path) { |
|---|
| 348 | | if(is_dir($directory_path)) { |
|---|
| 349 | | if($dh = opendir($directory_path)) { |
|---|
| 350 | | while(($file = readdir($dh)) !== false) { |
|---|
| 351 | | $file_path = $directory_path.$file; |
|---|
| 352 | | if(!$this->ignoreHiddenFiles || $file{0} != '.') { |
|---|
| 353 | | switch(filetype($file_path)) |
|---|
| 354 | | { |
|---|
| 355 | | case 'dir': |
|---|
| | 306 | /** |
|---|
| | 307 | * Create Cache |
|---|
| | 308 | * |
|---|
| | 309 | * - Scans the class dirs for class/interface definitions and |
|---|
| | 310 | * creates an associative array (class name => class file) |
|---|
| | 311 | * - Generates the array in PHP code and saves it as cache file |
|---|
| | 312 | * |
|---|
| | 313 | * @access private |
|---|
| | 314 | * @param param_type $param_name |
|---|
| | 315 | */ |
|---|
| | 316 | public function createCache() { |
|---|
| | 317 | /* Create class list */ |
|---|
| | 318 | foreach($this->classDirectories as $dir) { |
|---|
| | 319 | $this->parseDir($dir); |
|---|
| | 320 | } |
|---|
| | 321 | |
|---|
| | 322 | /* Generate php cache file */ |
|---|
| | 323 | $cache_content = "<?php\n\t// this is an automatically generated cache file.\n" |
|---|
| | 324 | ."\t// it serves as 'class name' / 'class file' association index for the SmartLoader\n"; |
|---|
| | 325 | foreach($this->classIndex as $class_name => $class_file) { |
|---|
| | 326 | $cache_content .= "\t\$classes['".$class_name."'] = '".$class_file."';\n"; |
|---|
| | 327 | } |
|---|
| | 328 | $cache_content .= " return \$classes; ?>"; |
|---|
| | 329 | if($cacheFilename_handle = fopen($this->cacheFilename, "w+")) { |
|---|
| | 330 | fwrite($cacheFilename_handle, $cache_content); |
|---|
| | 331 | /* Allow ftp users to access/modify/delete cache file, suppress chmod errors here */ |
|---|
| | 332 | @chmod($this->cacheFilename, 0664); |
|---|
| | 333 | } |
|---|
| | 334 | } |
|---|
| | 335 | |
|---|
| | 336 | /** |
|---|
| | 337 | * Parse Directory |
|---|
| | 338 | * |
|---|
| | 339 | * Parses a directory for class/interface definitions. Saves found definitions |
|---|
| | 340 | * in $classIndex. Needless to say: Mind recursion cycles when using symlinks. |
|---|
| | 341 | * TODO: Clean up this method; use SPL, if suitable. |
|---|
| | 342 | * |
|---|
| | 343 | * @access private |
|---|
| | 344 | * @param string $directory_path |
|---|
| | 345 | * @return boolean Success |
|---|
| | 346 | */ |
|---|
| | 347 | private function parseDir($directory_path) { |
|---|
| | 348 | if(is_dir($directory_path)) { |
|---|
| | 349 | if($dh = opendir($directory_path)) { |
|---|
| | 350 | while(($file = readdir($dh)) !== false) { |
|---|
| | 351 | $file_path = $directory_path.$file; |
|---|
| | 352 | if(!$this->ignoreHiddenFiles || $file{0} != '.') { |
|---|
| | 353 | switch(filetype($file_path)) |
|---|
| | 354 | { |
|---|
| | 355 | case 'dir': |
|---|
| 361 | | /* parse on recursively */ |
|---|
| 362 | | $this->parseDir($file_path.'/'); |
|---|
| 363 | | } |
|---|
| 364 | | break; |
|---|
| 365 | | case 'link': |
|---|
| 366 | | if($this->followSymlinks) { |
|---|
| 367 | | /* follow link, parse on recursively */ |
|---|
| 368 | | $this->parseDir($file_path.'/'); |
|---|
| 369 | | } |
|---|
| 370 | | break; |
|---|
| 371 | | case 'file': |
|---|
| 372 | | /* a non-empty endings array implies an ending check |
|---|
| 373 | | * TODO: Write a more sophisticated suffix check. */ |
|---|
| 374 | | if(!sizeof($this->classFileEndings) || in_array(substr($file, strrpos($file, '.')), $this->classFileEndings)) { |
|---|
| 375 | | if($php_file = fopen($file_path, "r")) { |
|---|
| | 361 | /* parse on recursively */ |
|---|
| | 362 | $this->parseDir($file_path.'/'); |
|---|
| | 363 | } |
|---|
| | 364 | break; |
|---|
| | 365 | case 'link': |
|---|
| | 366 | if($this->followSymlinks) { |
|---|
| | 367 | /* follow link, parse on recursively */ |
|---|
| | 368 | $this->parseDir($file_path.'/'); |
|---|
| | 369 | } |
|---|
| | 370 | break; |
|---|
| | 371 | case 'file': |
|---|
| | 372 | /* a non-empty endings array implies an ending check |
|---|
| | 373 | * TODO: Write a more sophisticated suffix check. */ |
|---|
| | 374 | if(!sizeof($this->classFileEndings) || in_array(substr($file, strrpos($file, '.')), $this->classFileEndings)) { |
|---|
| | 375 | if($php_file = fopen($file_path, "r")) { |
|---|