public static function load_model_definitions($dir = NULL) { if (!class_exists("Model")) { throw new Exception("an abstract Model class must be defined before calling ::load_model_definitions"); } if (!$dir) { $dir = './models'; } if (!isset($_SERVER['modelfiles'])) { $_SERVER['modelfiles'] = array(); } $dh = glob($dir . '/*'); foreach ($dh as $mfile) { if (preg_match('/^\\./', $mfile)) { continue; } $filetype = filetype($mfile); if ($filetype === 'file' && preg_match('/\\.php$/', $mfile)) { $_SERVER['modelfiles'][str_replace('.php', '', basename($mfile))] = $mfile; require_once $mfile; } else { if ($filetype === 'dir') { lib::load_model_definitions($mfile); } } } }