Example #1
0
	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' );
	}
Example #2
0
	public function index( $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL, $arg5 = NULL ){
		if( $this->env->getRequest()->has( 'resetInstanceId' ) ){
			$this->env->getSession()->remove( 'instanceId' );
			$this->restart( NULL );
		}

		$logicInstance	= Logic_Instance::getInstance( $this->env );
		$modelInstance	= new Model_Instance( $this->env );
		$instances		= $modelInstance->getAll();
		foreach( $instances as $instanceId => $instance ){
			$instance->modules	= $logicInstance->listModules( $instanceId );
		}
		$instanceId		= $this->env->getSession()->get( 'instanceId' );

		$this->addData( 'instances', $instances );
		$this->addData( 'instanceId', $instanceId );

		if( $instanceId ){
			$remote			= $this->env->getRemote();
			$logicModule	= Logic_Module::getInstance( $this->env );
			$this->env->clock->profiler->tick( 'Index::index: init' );

			$listModulesMissing		= array();
			$listModulesPossible	= array();
			$listModulesUpdate		= array();
			$modulesInstalled		= array();

			$modulesAll				= $logicModule->model->getAll();
			$this->env->clock->profiler->tick( 'Index::index: get all' );
			if( $remote instanceof CMF_Hydrogen_Environment_Remote ){
				$modulesInstalled		= $remote->getModules()->getAll();
				$this->env->clock->profiler->tick( 'Index::index: get installed' );

				foreach( $modulesInstalled as $module ){
					foreach( $module->relations->needs as $need )
						if( !array_key_exists( $need, $modulesInstalled ) )
							$listModulesMissing[]	= $need;
					foreach( $module->relations->supports as $support )
						if( !array_key_exists( $support, $modulesInstalled ) )
							$listModulesPossible[]	= $support;
				}
				$this->env->clock->profiler->tick( 'Index::index: get more' );

				foreach( $modulesInstalled as $module )
					if( $module->versionInstalled && $module->versionAvailable )
						if( version_compare( $module->versionAvailable, $module->versionInstalled ) > 0 )
							$listModulesUpdate[]	= $module;

				foreach( $listModulesMissing as $module ){
					$url	= './admin/module/installer/index/'.$module;
					$link	= UI_HTML_Tag::create( 'a', $module, array( 'href' => $url ) );
					$span	= UI_HTML_Tag::create( 'span', $link, array( 'class' => 'icon module module-status-4' ) );
					$this->env->getMessenger()->noteFailure( 'Modul '.$span.' ist nicht vollständig installiert.' );
				}
				$this->addData( 'remote', $remote );
				$this->addData( 'remoteConfig', $remote->getConfig() );
			}

			$this->addData( 'instance', $modelInstance->get( $instanceId ) );
			$this->addData( 'modulesAll', $modulesAll );
			$this->addData( 'modulesInstalled', $modulesInstalled );
			$this->addData( 'modulesMissing', $listModulesMissing );
			$this->addData( 'modulesPossible', $listModulesPossible );
			$this->addData( 'modulesUpdate', $listModulesUpdate );
		}

		$this->env->clock->profiler->tick( 'Index::index: done' );
	}