コード例 #1
0
ファイル: Environment.php5 プロジェクト: CeusMedia/Hydra
	protected function checkModules(){
#		CMC_Loader::registerNew( 'php5', NULL, 'classes/' );
#		$modelSource	= new Model_ModuleSource( $this );
#		$modelInstance	= new Model_Instance( $this );
		$logic			= Logic_Module::getInstance( $this );
#		remark( "Sources:" );
#		print_m( array_keys( $modelSource->getAll( FALSE ) ) );
#		remark( "Instances:" );
#		print_m( array_keys( $modelInstance->getAll( FALSE ) ) );
#		remark( "Categories:" );
#		print_m( $logic->getCategories() );
#		remark( "Modules installed:" );
#		print_m( array_keys( $logic->model->getInstalled() ) );

		try{
			$modules	= array(
	/*			'Resource_Library_cmModules'	=> array(
					'path'	=> CMF_PATH,
				),*/
				'Resource_Cache'			=> array(
					'type'		=> 'Folder',
					'resource'	=> 'tmp/cache/'
				),
				'Admin_Instances'			=> array(),
				'Admin_Modules'				=> array(),
				'Admin_Module_Sources'		=> array(),
				'Admin_Module_Installer'	=> array(),
				'Admin_Module_Editor'		=> array(),
				'Admin_Module_Creator'		=> array(),
				'JS_CodeMirror'				=> array(),
				'JS_jQuery'					=> array(),
				'JS_jQuery_UI'				=> array(),
				'JS_Layer'					=> array(),
				'UI_Helper_Content'			=> array(),
				'UI_CSS_Reset'				=> array(),
				'UI_DevLayers'				=> array(),
				'UI_Indicator'				=> array(),
				'UI_LockLayer'				=> array(),
			);
			$list	= array();
			foreach( $modules as $moduleId => $settings )
				if( !$this->getModules()->has( $moduleId ) )
					$list[$moduleId]	= $settings;

			$countAll	= count( $modules );
			$countHave	= $countAll - count( $list );

			if( $list){
				foreach( $list as $moduleId => $settings){
					$module		= $logic->getModule( $moduleId );
					$type		= Logic_Module::INSTALL_TYPE_LINK;
					$message	= $this->words['msg']['moduleAutoInstalled'];
					$logic->installModule( $module->source, $moduleId, $type, $settings, TRUE );
					$this->messenger->noteNotice( $message, $module->title );
				}
				header( 'Location: '.$this->url.$this->request->get( '__path' ) );
				exit;
			}
		}
		catch( Exception_Logic $e ){
			if( $e->getCode() == 2 ){
				$messages	= array();
				foreach( $e->getSubject() as $exception ){
					if( $exception instanceof Exception_IO )
						$messages[]	= '<li>'.$exception->getMessage().': '.$exception->getResource().'</li>';
					else
						$messages[]	= '<li>'.$exception->getMessage().'</li>';
				}
				$this->messenger->noteFailure( $e->getMessage().":<br/><ul>".join( $messages ).'</ul>' );
			}
		}
		catch( Exception $e ){
			die( UI_HTML_Exception_Page::display( $e ) );
		}
		$this->clock->profiler->tick( 'env: check: modules' );
	}
コード例 #2
0
ファイル: index.php プロジェクト: CeusMedia/FontAwesomeIndex
        //  use composer autoloader
    } else {
        if (empty($pathCmCommon)) {
            //  path to instance of CeusMedia/Common is NOT defined
            throw new Exception(sprintf('Install using composer or define path to instance of %s in %s!', '<a href="' . $uriGhCmCommon . '">CeusMedia/Common</a>', __FILE__));
        }
    }
    @(include $pathCmCommon . '/autoload.php');
    //  try to load CeusMedia/Common from local instance
    if (!class_exists('UI_HTML_PageFrame')) {
        //  instance of CeusMedia/Common is not existing
        throw new Exception(sprintf('Library %s not found in path %s.', '<a href="' . $uriGhCmCommon . '">CeusMedia/Common</a>', $pathCmCommon));
    }
    require_once 'inc/FontAwesomeIndex.php';
    //  load main application class
    $darkMode = isset($darkMode) ? $darkMode : isset($_REQUEST['darkMode']);
    //  have an eye on dark mode
    new FontAwesomeIndex($darkMode);
    //  run main application
} catch (Exception $e) {
    //  catch exceptions on library load or application run
    if (class_exists('UI_HTML_Exception_Page')) {
        //  exception display of CeusMedia/Common is available
        UI_HTML_Exception_Page::display($e);
        //  display exception
    } else {
        //  library loading failed
        print $e->getMessage() . PHP_EOL;
        //  quit with exception message
    }
}
コード例 #3
0
ファイル: Index.php5 プロジェクト: CeusMedia/Hydra
	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;
	}