function classFolder($className, $folder = 'aplikasi') { $dir = dir(ROOT_DIR . $folder); if ($folder == 'aplikasi' && file_exists(ROOT_DIR . $folder . '/' . $className . '.php')) { return $folder . '/' . $className . '.php'; } else { while (false !== ($entry = $dir->read())) { $checkFolder = $folder . '/' . $entry; if (strlen($entry) > 2) { if (is_dir(ROOT_DIR . $checkFolder)) { if (file_exists(ROOT_DIR . $checkFolder . '/' . $className . '.php')) { return $checkFolder . '/' . $className . '.php'; } else { $subFolder = classFolder($className, $checkFolder); if ($subFolder) { return $subFolder; } } } } } } $dir->close(); return 0; }
/** * search for folders and subfolders with classes * * @param $className string * @param $sub string[optional] * @return string */ function classFolder($className, $sub = "/") { $dir = dir(CLASS_DIR . $sub); if (file_exists(CLASS_DIR . $sub . $className . ".class.php")) { return CLASS_DIR . $sub; } while (false !== ($folder = $dir->read())) { if ($folder != "." && $folder != "..") { if (is_dir(CLASS_DIR . $sub . $folder)) { $subFolder = classFolder($className, $sub . $folder . "/"); if ($subFolder) { return $subFolder; } } } } $dir->close(); return false; }