Exemple #1
0
	public function __construct( $forceInstanceId = NULL ){

		self::$classRouter	= 'CMF_Hydrogen_Environment_Router_Recursive';
		self::$configFile	= "config/config.ini";

		date_default_timezone_set( "Europe/Berlin" );

		$this->detectSelf();

		$this->checkConfig();																		//  create main configuation if missing
		$this->checkInstances();																	//  create setup tool as first instance of none are defined yet
		$this->checkSources();																		//  create local cmFrameworks copy as first module source of none are defined yet
		$this->checkThemes();																		//  link in petrol theme is missing

		$this->pathConfig	= '';

		$this->pathModules	= dirname( __DIR__ ).'/vendor/ceus-media/hydrogen-modules/';			//  get path to public modules

		$this->path			= dirname( getEnv( 'SCRIPT_FILENAME' ) ).'/';
		if( isset( $options['pathApp'] ) )
			$this->path		= $options['pathApp'];													//	@todo: is this needed after migration of setup to CMF/Tools/Hydrogen ?

		$this->initClock();																			//  setup clock
		$this->initConfiguration();																	//  setup configuration
		$this->initModules();																		//  setup module support

		if( !$this->getModules()->has( 'Admin_Module_Sources' ) )									//  source administration module not installed yet
			require_once $this->pathModules.'Admin/Module/Sources/classes/Model/ModuleSource.php5';	//  load atleast module source model class
		if( !$this->getModules()->has( 'Admin_Instances' ) )										//  instance administration module not installed yet
			require_once $this->pathModules.'Admin/Instances/classes/Model/Instance.php5';			//  load atleast instance model class
		if( !$this->getModules()->has( 'Admin_Modules' ) ){											//  module administration module not installed yet
			require_once $this->pathModules.'Admin/Modules/classes/Model/Module.php5';				//  load atleast module model class
			require_once $this->pathModules.'Admin/Modules/classes/Logic/Module.php5';				//  and module logic class for installating missing modules
		}

		$this->initSession();																		//  setup session support
		$this->initMessenger();																		//  setup user interface messenger
		$this->initDatabase();																		//  setup database connection
		$this->initCache();																			//  setup cache support
		$this->initRequest();																		//  setup HTTP request handler
		$this->initResponse();																		//  setup HTTP response handler
		$this->initRouter();																		//  setup request router
		$this->initLanguage();																		//  setup language support
		$this->initPage();																			//  
		$this->initAcl();																			//  
		$this->initRemote( $this->request->get( 'forceInstanceId' ) );														//  
		$this->words	= $this->language->getWords( 'main' );
		$this->__onInit();																			//  
		$this->checkModules();																		//  try to install missing modules
	}
Exemple #2
0
	public function showInstanceModuleGraph( $instanceId = NULL, $showExceptions = NULL ){
		try{
			if( !UI_Image_Graphviz_Renderer::checkGraphvizSupport() )
				throw new InvalidArgumentException( "No GraphViz support detected" );

			$instanceId		= $this->env->getSession()->get( 'instanceId' );
			if( !$instanceId )
				throw new InvalidArgumentException( "No instance selected" );

/*	--  SADLY this code breaks for some instances on creation of remove environment, so no support for requested instances :-(
			if( $instanceId ){
				$model		= new Model_Instance( $this->env );
				$instance	= $model->get( $instanceId );
				if( !$instance )
					throw new InvalidArgumentException( "Invalid instance ID" );
				$pathConfig	= !empty( $instance->pathConfig ) ? $instance->pathConfig : 'config/';
				$fileConfig	= !empty( $instance->pathFile ) ? $instance->pathFile : 'config.ini';
				if( !file_exists( $instance->uri.$pathConfig.$fileConfig ) )
					throw new RuntimeException( 'Instance config file missing' );
				$options	= array(
					'configFile'	=> $instance->uri.$pathConfig.$fileConfig,
					'pathApp'		=> $instance->uri
				);
				try{
					$remote		= new CMF_Hydrogen_Environment_Remote( $options );
					$modules	= $remote->getModules()->getAll();
				}
				catch( Exception $e ){
					UI_HTML_Exception_Page::display( $e );
					exit;
				}
			}
			else
				$modules	= $this->env->remote->getModules()->getAll();
*/
			if( !$this->env->remote->getModules() )
				throw new RuntimeException( 'Instance has no modules' );
			$modules	= $this->env->remote->getModules()->getAll();
			ksort( $modules );

			$nodeOptions	= array( 'shape' => 'oval', 'style' => 'filled, rounded', 'fontsize' => 10, 'fillcolor' => 'gray90', 'color' => "gray60" );
			$edgeOptions1	= array( 'arrowsize' => 0.5, 'fontsize' => 8, 'fontcolor' => 'gray50', 'color' => 'gray40' );
			$edgeOptions2	= array( 'arrowsize' => 0.5, 'fontsize' => 8, 'fontcolor' => 'gray75', 'color' => 'gray50', 'style' => 'dashed' );

			$graph		= new UI_Image_Graphviz_Graph( $instanceId, array( 'rankdir' => 'LR' ) );
			foreach( $modules as $module )
				$graph->addNode( $module->id, array( 'label' => $module->title ) + $nodeOptions );
			foreach( $modules as $module ){
				foreach( $module->relations->needs as $related )
					$graph->addEdge( $module->id, $related, array( 'label' => 'needs' ) + $edgeOptions1 );
				foreach( $module->relations->supports as $related )
					if( array_key_exists( $related, $modules ) )
						$graph->addEdge( $module->id, $related, array( 'label' => 'supports' ) + $edgeOptions2 );
			}
			$renderer	= new UI_Image_Graphviz_Renderer( $graph );
			$renderer->printGraph( "svg" );
		}
		catch( Exception $e ){
			if( $showExceptions )
				UI_HTML_Exception_Page::display( $e );
			new UI_Image_Error( $e->getMessage() );
		}
		exit;
	}
Exemple #3
0
<?php

require_once 'vendor/autoload.php';
require_once 'vendor/ceus-media/common/compat.php';
define('CMC_PATH', 'vendor/ceus-media/common/src/');
define('CMF_PATH', 'vendor/ceus-media/hydrogen-framework/src/');
Loader::registerNew('php5', 'Tool_Hydrogen_Setup_', 'classes/');
Loader::registerNew('php5', '', 'classes/');
/*  --  RUN APPLICATION  --  */
try {
    Tool_Hydrogen_Setup_App::$classEnvironment = "Tool_Hydrogen_Setup_Environment";
    Tool_Hydrogen_Setup_Environment::$configFile = "config/config.ini";
    $app = new Tool_Hydrogen_Setup_App();
    $app->run();
} catch (Exception $e) {
    UI_HTML_Exception_Page::display($e);
}