From: Geoffrey T. D. <da...@us...> - 2001-09-19 19:16:32
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv11726/lib Modified Files: config.php Added Files: FileFinder.php Log Message: New file lib/FileFinder.php with utility code to help find source files. ***** Error reading new file: [Errno 2] No such file or directory: 'FileFinder.php' Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** config.php 2001/09/19 02:27:50 1.42 --- config.php 2001/09/19 19:16:27 1.43 *************** *** 24,52 **** $FieldSeparator = "\x81"; // Search PHP's include_path to find file or directory. function FindFile ($file, $missing_okay = false) { ! // FIXME: This wont work for DOS filenames. ! if (ereg('^/', $file)) ! { ! // absolute path. ! if (file_exists($file)) ! return $file; ! } ! else ! { ! $include_path = ini_get('include_path'); ! if (empty($include_path)) ! $include_path = '.'; ! // FIXME: This wont work for DOS filenames. ! $path = explode(':', $include_path); ! while (list($i, $dir) = each ($path)) ! if (file_exists("$dir/$file")) ! return "$dir/$file"; ! } ! ! if (!$missing_okay) ! ExitWiki("$file: file not found"); ! return false; } --- 24,35 ---- $FieldSeparator = "\x81"; + require_once('lib/FileFinder.php'); // Search PHP's include_path to find file or directory. function FindFile ($file, $missing_okay = false) { ! static $finder; ! if (!isset($finder)) ! $finder = new FileFinder; ! return $finder->findFile($file, $missing_okay); } *************** *** 55,87 **** function FindLocalizedFile ($file, $missing_okay = false) { ! $language = $GLOBALS['LANG']; ! ! if (empty($language)) ! $language = getenv("LC_ALL"); ! if (empty($language)) ! $language = getenv("LC_MESSAGES"); ! if (empty($language)) ! $language = getenv("LC_RESPONSES"); // deprecated ! if (empty($language)) ! $language = getenv("LANG"); ! if (empty($language)) ! $language = "C"; ! ! // FIXME: This wont work for DOS filenames. ! if (!ereg('^/', $file)) ! { ! if ( ($path = FindFile("locale/$language/$file", 'missing_is_okay')) ) ! return $path; ! // A locale can be, e.g. de_DE.iso8859-1@euro. ! // Try less specific versions of the locale: ! $seps = array('@', '.', '_'); ! for ($i = 0; $i < count($seps); $i++) ! if ( ($tail = strchr($language, $seps[$i])) ) { ! $head = substr($language, 0, -strlen($tail)); ! if ( ($path = FindFile("locale/$head/$file", 'missing_is_okay')) ) ! return $path; ! } ! } ! return FindFile($file, $missing_okay); } --- 38,45 ---- function FindLocalizedFile ($file, $missing_okay = false) { ! static $finder; ! if (!isset($finder)) ! $finder = new LocalizedFileFinder; ! return $finder->findFile($file, $missing_okay); } |