/** * 自动加载类 * @param String $className 类名 * @throws Exception */ function loader($className) { $file = getClassFile($className); if (is_file($file)) { require_once $file; } }
public function viewClass(SS_HTTPRequest $request) { $class = $request->param('Class'); if (!class_exists($class)) { throw new Exception('CodeViewer->viewClass(): not passed a valid class to view (does the class exist?)'); } return $this->customise(array('Content' => $this->testAnalysis(getClassFile($class))))->renderWith('CodeViewer'); }
/** * Check if database needs to be built, and build it if it does. */ static function autoBuild() { $dataClasses = ClassInfo::subclassesFor('DataObject'); $lastBuilt = self::lastBuilt(); foreach ($dataClasses as $class) { if (filemtime(getClassFile($class)) > $lastBuilt) { $da = new DatabaseAdmin(); $da->doBuild(true); return; } } }
function getClassFile ($fileName, $path = '/') { $dirPath = 'scripts' . $path; if (file_exists($dirPath . $fileName)) return $dirPath . $fileName; $dir = dir($dirPath); while (($subdir = $dir->read()) !== false) { if ($subdir == '.' || $subdir == '..') continue; if (!is_dir($dirPath . $subdir)) continue; $classFile = getClassFile($fileName, $path . $subdir . '/'); if ($classFile) return $classFile; } $dir->close(); return false; }
function autoload($className) { $fileName = dirname(__DIR__) . '/' . str_replace('\\', '/', $className) . '.php'; echobr('当前要实例化的:' . $fileName); //echo $fileName; if (file_exists($fileName)) { include $fileName; //echo $className . '<br>'; //只要require文件就可以了我擦... //return new $className; } else { $fileName = getClassFile($className); if ($fileName) { include $fileName; } } }
function Content() { $className = $this->urlParams['ID']; if ($className && ClassInfo::exists($className)) { return $this->testAnalysis(getClassFile($className)); } else { $result = "<h1>View any of the following test classes</h1>"; $classes = ClassInfo::subclassesFor('SapphireTest'); ksort($classes); foreach ($classes as $className) { if ($className == 'SapphireTest') { continue; } $result .= "<li><a href=\"TestViewer/show/{$className}\">{$className}</a></li>"; } return $result; } }
function Content() { $className = $this->urlParams['ID']; if($className && ClassInfo::exists($className)) { return $this->testAnalysis(getClassFile($className)); } else { $result = "<h1>View any of the following test classes</h1>"; $classes = ClassInfo::subclassesFor('SapphireTest'); ksort($classes); foreach($classes as $className) { if($className == 'SapphireTest') continue; $result .= "<li><a href=\"dev/viewcode/show/$className\">$className</a></li>"; } $result .= "<h1>View any of the following other classes</h1>"; global $_CLASS_MANIFEST; $classes = array_keys(ClassInfo::allClasses()); sort($classes); foreach($classes as $className) { if(preg_match('/^[A-Za-z][A-Za-z0-9]*$/', $className) && isset($_CLASS_MANIFEST[$className])) { $result .= "<li><a href=\"dev/viewcode/show/$className\">$className</a></li>"; } } return $result; } }