public static function find_file($dir, $file, $ext = NULL, $array = FALSE) { if ($ext === NULL) { $ext = EXT; } elseif ($ext) { $ext = ".{$ext}"; } else { $ext = ""; } $path = $dir . DIRECTORY_SEPARATOR . $file . $ext; if (JsonApiApplication::$caching === TRUE and isset(JsonApiApplication::$_files[$path . ($array ? "_array" : "_path")])) { return JsonApiApplication::$_files[$path . ($array ? "_array" : "_path")]; } if (JsonApiApplication::$profiling === TRUE and class_exists("Profiler", FALSE)) { $benchmark = Profiler::start("JsonApiApplication", __FUNCTION__); } if ($array or $dir === "config" or $dir === "i18n" or $dir === "messages") { $paths = array_reverse(JsonApiApplication::$_paths); $found = array(); foreach ($paths as $dir) { if (is_file($dir . $path)) { $found[] = $dir . $path; } } } else { $found = FALSE; foreach (JsonApiApplication::$_paths as $dir) { if (is_file($dir . $path)) { $found = $dir . $path; break; } } } if (JsonApiApplication::$caching === TRUE) { JsonApiApplication::$_files[$path . ($array ? "_array" : "_path")] = $found; JsonApiApplication::$_files_changed = TRUE; } if (isset($benchmark)) { Profiler::stop($benchmark); } return $found; }