コード例 #1
0
ファイル: File.class.php プロジェクト: Superbeest/Core
 /**
  * This function is identical to the getFullPath() function, except that it strips the given
  * $base variable from the beginning of the file. If the given base is not found, it returns the regular getFullPath() result.
  * The base variable gets normalised before checking.
  * @param string The base to remove from the beginning
  * @return string The remaining fullpath string
  */
 public final function stripBase($base)
 {
     $path = $this->getFullPath();
     $base = \System\IO\Directory::normalize($base) ?: \System\IO\Directory::getPath($base);
     $startPos = stripos($path, $base);
     if ($startPos !== false && $startPos == 0) {
         return substr($path, strlen($base));
     }
     return $path;
 }
コード例 #2
0
ファイル: APIGen.class.php プロジェクト: Superbeest/Core
 /**
  * Generates the API documentation for the System and the Module namespace.
  * It only includes PHP classes and will output PHP files in the given target directory.
  * This function is also applicable on a running system.
  * The target folder will be cleared!
  * @param \System\IO\Directory The target folder to use. This folder must be writable
  */
 public static final function generateAPIDoc(\System\IO\Directory $targetFolder)
 {
     //delete all files before actual adding, so we dont append to old files
     $files = \System\IO\Directory::walkDir($targetFolder->getCurrentPath(), new \System\Collection\Vector('php'));
     foreach ($files as $file) {
         $file->delete();
     }
     //first we have to load all the php files in the current System and Module folders
     $systemFiles = \System\IO\Directory::walkDir(PATH_SYSTEM, new \System\Collection\Vector('php'));
     foreach ($systemFiles as $systemFile) {
         if (!in_array($systemFile->getFilename(), self::$excludeFiles)) {
             require_once $systemFile->getFullPath();
         }
     }
     $vec = \System\Module\Module::getAllModules();
     //echo '<pre>';
     $moduleList = new \System\Collection\Vector();
     foreach ($vec as $module) {
         $manifest = strtolower(str_ireplace('Module\\', '', str_ireplace('\\Module', '', $module->manifest))) . '\\';
         $moduleList[] = $manifest;
     }
     $moduleFiles = \System\IO\Directory::walkDir(PATH_MODULES, new \System\Collection\Vector('php'));
     foreach ($moduleFiles as $moduleFile) {
         $base = $moduleFile->stripBase(PATH_MODULES);
         $found = false;
         foreach ($moduleList as $entry) {
             if (stripos(str_replace('\\', '/', $base), str_replace('\\', '/', $entry)) === 0) {
                 $found = true;
                 break;
             }
         }
         if ($found) {
             require_once $moduleFile->getFullPath();
         }
     }
     foreach (get_declared_interfaces() as $interface) {
         $reflectionClass = new \ReflectionClass($interface);
         if ($reflectionClass->getFileName() != '' && (strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_MODULES)) !== false || strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_SYSTEM)) !== false)) {
             self::generateClassDocumentation($targetFolder, $reflectionClass);
         }
     }
     foreach (get_declared_classes() as $class) {
         $reflectionClass = new \ReflectionClass($class);
         if ($reflectionClass->getFileName() != '' && (strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_MODULES)) !== false || strpos(\System\IO\Directory::normalize($reflectionClass->getFileName()), \System\IO\Directory::normalize(PATH_SYSTEM)) !== false)) {
             self::generateClassDocumentation($targetFolder, $reflectionClass);
         }
     }
     /*$constants = get_defined_constants(true);
     		echo '<pre>';
     		$moduleConstants = new \System\Collection\Map();
     		$systemConstants = new \System\Collection\Map();
     		foreach ($constants['user'] as $key=>$value)
     		{
     			switch (true)
     			{
     				case stripos($key, 'system\\') === 0:
     					$systemConstants[$key] = $value;
     					break;
     				case stripos($key, 'module\\') === 0:
     					$moduleConstants[$key] = $value;
     					break;
     				default:
     					//dont do anything
     			}
     		}
     
     		foreach ($systemConstants as $key=>$value)
     		{
     			self::writeConstant($targetFolder, $key, $value);
     		}
     
     		foreach ($moduleConstants as $key=>$value)
     		{
     			self::writeConstant($targetFolder, $key, $value);
     		}*/
     //copy the copy extensions
     $vec = new \System\Collection\Vector(self::$copyExtensions);
     self::copyFiles($targetFolder, PATH_MODULES, $vec, 'module');
     self::copyFiles($targetFolder, PATH_SYSTEM, $vec, 'system');
 }