/** * Searches in the specified mapping cache for $LibraryName. If a mapping is * found, it returns it. If not, it searches through the application * directories $Depth levels deep looking for $LibraryName. Returns FALSE * if not found. * * @param string $MappingsFileName The name of the mappings file to look in for library mappings. These * files are contained in the application's /cache folder. * @param string $SourceFolders The path to the folders that should be considered the "root" of this search. * @param mixed $FolderWhiteList A white-list array of sub-folders within $SourceFolder in which the * search can be performed. If FALSE is specified instead, the search will * only be performed in $SourceFolders. * @param string $LibraryName The name of the library to search for. This is a valid file name. * ie. "class.database.php" */ public static function findByMapping($MappingCacheName, $SourceFolders, $FolderWhiteList, $LibraryName) { // If the application folder was provided, it will be the only entry in the whitelist, so prepend it. if (is_array($FolderWhiteList) && count($FolderWhiteList) == 1) { $LibraryName = combinePaths(array($FolderWhiteList[0], $LibraryName)); } $LibraryKey = str_replace('.', '__', $LibraryName); Gdn_LibraryMap::prepareCache($MappingCacheName); $LibraryPath = Gdn_LibraryMap::getCache($MappingCacheName, $LibraryKey); if ($LibraryPath === null) { // $LibraryName wasn't contained in the mappings array. // I need to look through the folders in this application for the requested file. // Once I find it, I need to save the mapping so we don't have to search for it again. // Attempt to find the file directly off the root (if the app folder was provided in the querystring) /*if ($FolderWhiteList !== FALSE && count($FolderWhiteList) == 1) { $LibraryPath = self::Find($SourceFolders, $LibraryName); } else { $LibraryPath = self::Find($SourceFolders, $LibraryName, $FolderWhiteList); }*/ $LibraryPath = self::find($SourceFolders, $LibraryName, $FolderWhiteList); // If the mapping was found if ($LibraryPath !== false) { Gdn_LibraryMap::cache($MappingCacheName, $LibraryKey, $LibraryPath); } } return $LibraryPath; }