Ejemplo n.º 1
0
 private static final function checkModuleManifestLoaded(array $finalParts)
 {
     //we want to prohibit the access of modules before they are loaded.
     //but in order to do that, we need to make sure the module system is loaded.
     //if the module system is not loaded, extra modules cannot be loaded aswell, so we can safely continue in this case.
     //we dont autoload the module system, this whould cause an infinite recursive loop
     if (!self::$moduleSystemLoaded) {
         if (class_exists('\\System\\Module\\Module', false)) {
             self::$moduleSystemLoaded = true;
         } else {
             return true;
         }
     }
     //here we can check if the $class variable is in a module namespace
     if ($finalParts[0] == 'module' && mb_strtolower(end($finalParts)) != 'module') {
         //$class
         $modules = \System\Module\Module::getAllModules();
         $fullClassName = implode('\\', $finalParts);
         foreach ($modules as $module) {
             $loadedModuleManifest = implode('\\', array_slice(explode('\\', strtolower($module->manifest)), 0, 2)) . '\\';
             $moduleNameParts = array_slice($finalParts, 0, 2);
             $moduleName = implode('\\', $moduleNameParts);
             if (strpos($fullClassName, $loadedModuleManifest) === 0) {
                 return true;
             }
         }
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 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');
 }
Ejemplo n.º 3
0
 /**
  * Outputs the systeminfo in a human readable format.
  * This function outputs html styled information and should only be used for displaying information.
  * @return string The html styled system information
  */
 public static final function getSystemInfo()
 {
     $output = '';
     $output .= '<table style="margin: 10px; font-family: Verdana; font-size: 12px; width: 600px; border: 1px solid black; background-color: #9999cc;">
                     <tr><td colspan="2">
                     <p style="font-size: 14px; font-weight: bold;">SYSTEM INFORMATION</p>
                     <p style="font-size: 10px;">
                         Notice: This file is copyrighted and unauthorized use is strictly prohibited.<br />
                         The file contains proprietary information and may not be distributed, modified<br />
                         or altered in any way, without written perimission.<br />
                         Copyright: SUPERHOLDER B.V. ' . date('Y') . '
                     </p>
                     </td></tr>
                 </table>';
     $info = new \System\Collection\Vector();
     $system = new \System\Collection\Map();
     $system->name = 'SYSTEM Namespace';
     $system->manifest = 'N/A';
     $system->major = self::getMajor();
     $system->minor = self::getMinor();
     $system->revision = self::getSourceRevision();
     $map = new \System\Collection\Map();
     $map->PHP = self::getPHPVersion();
     $map->hasSlowQueryListener = \System\Event\EventHandler::hasListeners('\\System\\Event\\Event\\OnSlowMySQLQueryEvent') ? 'true' : 'false';
     if (self::$configDirectives == null) {
         self::$configDirectives = new \System\Collection\Vector();
     }
     $map->requiredConfigDirectives = implode(', ', self::$configDirectives->getArrayCopy());
     $map->PATH_PROJECT = PATH_PROJECT;
     $map->PATH_SYSTEM = PATH_SYSTEM;
     $map->PATH_CONFIG = PATH_CONFIG;
     $map->PATH_TEMP = PATH_TEMP;
     $map->PATH_LOGS = PATH_LOGS;
     $map->PATH_MODULES = PATH_MODULES;
     $map->installedCaches = 'LUTCache, Memcache, APCCache';
     $system->additional = $map;
     $info[] = $system;
     $info->combine(\System\Module\Module::getAllModules());
     foreach ($info as $module) {
         $output .= '<table style="margin: 10px; font-family: Verdana; font-size: 12px; width: 600px; border: 1px solid black; background-color: #9999cc;">';
         $output .= '<tr><td colspan="2" style="text-align: center; font-weight: bold; font-size: 14px;">' . $module->name . '</td></tr>';
         $output .= '<tr><td style="background-color: #ccccff; width: 200px;">Manifest</td><td style="background-color: #cccccc; width: 400px;">' . $module->manifest . '</td></tr>';
         $output .= '<tr><td style="background-color: #ccccff; width: 200px;">Version</td><td style="background-color: #cccccc; width: 400px;">' . $module->major . "." . $module->minor . "." . $module->revision . '</td></tr>';
         foreach ($module->additional as $index => $value) {
             $output .= '<tr><td style="background-color: #ccccff; width: 200px;">' . $index . '</td><td style="background-color: #cccccc; width: 400px;">' . $value . '</td></tr>';
         }
         $output .= '</table>';
     }
     return $output;
 }
 /**
  * Gets all the loaded modules. Listens to the EVENT_GET_LOADED_MODULES message
  * @param OnInteractionEvent The event to listen to
  */
 public static final function getLoadedModules(\System\System\Interaction\Event\OnInteractionEvent $event)
 {
     $msg = $event->getMessage();
     if ($msg->getType() == \System\System\Interaction\MessageType::TYPE_SYSTEM && $msg->getMessage() == SystemInteractionEventEvent::EVENT_GET_LOADED_MODULES) {
         $response = new \System\System\Interaction\Response($msg, \System\Module\Module::getAllModules());
         $event->addResponse($response);
     }
 }