src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
protected function initController($name, $selfedit) {
		$this->instanceName = $name;
		$this->selfedit = $selfedit;
		/*$this->instance = MoufManager::getMoufManager()->getInstance($name);
		$this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/
		
		if ($selfedit == "true") {
			$this->moufManager = MoufManager::getMoufManager();
		} else {
			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
		}
		
		$this->className = $this->moufManager->getInstanceType($this->instanceName);		
		//$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true");
		
		$this->weak = $this->moufManager->isInstanceWeak($this->instanceName);
		
		// Init the right menu:
		/*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction");
		if (!empty($extendedActions)) {
			$items = array();
			foreach ($extendedActions as $extendedAction) {
				$menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl());
				$menuItem->setPropagatedUrlParameters(array("selfedit", "name"));
				$items[] = $menuItem;
			}
			$specialActionsMenuItem = new MenuItem("Special actions", null, $items);
						
			//$menu = new Menu($items);
			\MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem);
			
			//$this->template->addRightHtmlElement($menuItems);	
		}*/
		
		$viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/");
		$viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));
		
		if (!$viewPropertiesMenuItem->isActive()) {
			// If the view is active, we might as well not display anything!
			\MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem);
			
		}
		
		/*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/");
		$viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/
		//$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/));
		/*$this->template->addRightHtmlElement(new SplashMenu(
			array(
			new SplashMenuItem("<b>Common</b>", null, null),
			new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")),
			new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit")))));
		$this->template->addRightFunction(array($this, "displayComponentParents"));
		*/
		
		// Let's find the documentation related to this class.
		// Note: the class name can be null in case of some instances declared via PHP code.
		if ($this->className) {
			
			$cache = new MoufCache();
			
			$documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className);
	
			if ($documentationMenuItem === null) {
				$documentationMenuItem = new MenuItem("<b>Related documentation</b>");
				// TODO: hit the documentation menu instead!
				
				if ($this->selfedit == "true") {
					$composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className);
				} else {
					$documentationUtils = new ClassProxy('Mouf\\DocumentationUtils');
					$composerJsonFiles = $documentationUtils->getRelatedPackages($this->className);
				}
				
				foreach ($composerJsonFiles as $composerJsonFile) {
					$parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true);
					$extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array();
					$docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/');
					
					if (isset($parsedJsonFile['name']) && $docPages) {
						$packageName = $parsedJsonFile['name'];
						
						$packageDocumentation = new MenuItem($packageName);
						$documentationMenuItem->addMenuItem($packageDocumentation);
						
						DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName);
					} else {
						// This is probably the root package if it has no name.
						continue;
					}
				}
				// Short lived cache (3 minutes)
				$cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180);
			}
			
			if ($documentationMenuItem->getChildren()) {
				\MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem);
			}
		}
		
		//\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>");
		
		$this->displayComponentParents();
	}
protected function initController($name, $selfedit) {
		$this->instanceName = $name;
		$this->selfedit = $selfedit;
		/*$this->instance = MoufManager::getMoufManager()->getInstance($name);
		$this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/
		
		if ($selfedit == "true") {
			$this->moufManager = MoufManager::getMoufManager();
		} else {
			$this->moufManager = MoufManager::getMoufManagerHiddenInstance();
		}
		
		$this->className = $this->moufManager->getInstanceType($this->instanceName);		
		//$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true");
		
		$this->weak = $this->moufManager->isInstanceWeak($this->instanceName);
		
		// Init the right menu:
		/*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction");
		if (!empty($extendedActions)) {
			$items = array();
			foreach ($extendedActions as $extendedAction) {
				$menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl());
				$menuItem->setPropagatedUrlParameters(array("selfedit", "name"));
				$items[] = $menuItem;
			}
			$specialActionsMenuItem = new MenuItem("Special actions", null, $items);
						
			//$menu = new Menu($items);
			\MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem);
			
			//$this->template->addRightHtmlElement($menuItems);	
		}*/
		
		$viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/");
		$viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));
		
		if (!$viewPropertiesMenuItem->isActive()) {
			// If the view is active, we might as well not display anything!
			\MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem);
			
		}
		
		/*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/");
		$viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/
		//$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/));
		/*$this->template->addRightHtmlElement(new SplashMenu(
			array(
			new SplashMenuItem("<b>Common</b>", null, null),
			new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")),
			new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit")))));
		$this->template->addRightFunction(array($this, "displayComponentParents"));
		*/
		
		// Let's find the documentation related to this class.
		// Note: the class name can be null in case of some instances declared via PHP code.
		if ($this->className) {
			
			$cache = new MoufCache();
			
			$documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className);
	
			if ($documentationMenuItem === null) {
				$documentationMenuItem = new MenuItem("<b>Related documentation</b>");
				// TODO: hit the documentation menu instead!
				
				if ($this->selfedit == "true") {
					$composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className);
				} else {
					$documentationUtils = new ClassProxy('Mouf\\DocumentationUtils');
					$composerJsonFiles = $documentationUtils->getRelatedPackages($this->className);
				}
				
				foreach ($composerJsonFiles as $composerJsonFile) {
					$parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true);
					$extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array();
					$docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/');
					
					if (isset($parsedJsonFile['name']) && $docPages) {
						$packageName = $parsedJsonFile['name'];
						
						$packageDocumentation = new MenuItem($packageName);
						$documentationMenuItem->addMenuItem($packageDocumentation);
						
						DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName);
					} else {
						// This is probably the root package if it has no name.
						continue;
					}
				}
				// Short lived cache (3 minutes)
				$cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180);
			}
			
			if ($documentationMenuItem->getChildren()) {
				\MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem);
			}
		}
		
		//\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>");
		
		$this->displayComponentParents();
	}
protected function initController ( $ name , $ selfedit ) { $ this -> instanceName = $ name ; $ this -> selfedit = $ selfedit ; /*$this->instance = MoufManager::getMoufManager()->getInstance($name);
		$this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/ if ( $ selfedit == "true" ) { $ this -> moufManager = MoufManager :: getMoufManager ( ) ; } else { $ this -> moufManager = MoufManager :: getMoufManagerHiddenInstance ( ) ; } $ this -> className = $ this -> moufManager -> getInstanceType ( $ this -> instanceName ) ; //$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true"); $ this -> weak = $ this -> moufManager -> isInstanceWeak ( $ this -> instanceName ) ; // Init the right menu: /*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction");
		if (!empty($extendedActions)) {
			$items = array();
			foreach ($extendedActions as $extendedAction) {
				$menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl());
				$menuItem->setPropagatedUrlParameters(array("selfedit", "name"));
				$items[] = $menuItem;
			}
			$specialActionsMenuItem = new MenuItem("Special actions", null, $items);
						
			//$menu = new Menu($items);
			\MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem);
			
			//$this->template->addRightHtmlElement($menuItems);	
		}*/ $ viewPropertiesMenuItem = new MenuItem ( "View properties" , ROOT_URL . "ajaxinstance/" ) ; $ viewPropertiesMenuItem -> setPropagatedUrlParameters ( array ( "selfedit" , "name" ) ) ; if ( ! $ viewPropertiesMenuItem -> isActive ( ) ) { // If the view is active, we might as well not display anything! \ MoufAdmin :: getInstanceMenu ( ) -> addChild ( $ viewPropertiesMenuItem ) ; } /*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/");
		$viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/ //$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/)); /*$this->template->addRightHtmlElement(new SplashMenu(
			array(
			new SplashMenuItem("<b>Common</b>", null, null),
			new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")),
			new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit")))));
		$this->template->addRightFunction(array($this, "displayComponentParents"));
		*/ // Let's find the documentation related to this class. // Note: the class name can be null in case of some instances declared via PHP code. if ( $ this -> className ) { $ cache = new MoufCache ( ) ; $ documentationMenuItem = $ cache -> get ( 'documentationMenuForClass_' . $ this -> className ) ; if ( $ documentationMenuItem === null ) { $ documentationMenuItem = new MenuItem ( "<b>Related documentation</b>" ) ; // TODO: hit the documentation menu instead! if ( $ this -> selfedit == "true" ) { $ composerJsonFiles = DocumentationUtils :: getRelatedPackages ( $ this -> className ) ; } else { $ documentationUtils = new ClassProxy ( 'Mouf\\DocumentationUtils' ) ; $ composerJsonFiles = $ documentationUtils -> getRelatedPackages ( $ this -> className ) ; } foreach ( $ composerJsonFiles as $ composerJsonFile ) { $ parsedJsonFile = json_decode ( file_get_contents ( $ composerJsonFile ) , true ) ; $ extra = isset ( $ parsedJsonFile [ 'extra' ] ) ? $ parsedJsonFile [ 'extra' ] : array ( ) ; $ docPages = DocumentationUtils :: getDocPages ( $ extra , dirname ( $ composerJsonFile ) . '/' ) ; if ( isset ( $ parsedJsonFile [ 'name' ] ) && $ docPages ) { $ packageName = $ parsedJsonFile [ 'name' ] ; $ packageDocumentation = new MenuItem ( $ packageName ) ; $ documentationMenuItem -> addMenuItem ( $ packageDocumentation ) ; DocumentationUtils :: fillMenu ( $ packageDocumentation , $ docPages , $ packageName ) ; } else { // This is probably the root package if it has no name. continue ; } } // Short lived cache (3 minutes) $ cache -> set ( 'documentationMenuForClass_' . $ this -> className , $ documentationMenuItem , 180 ) ; } if ( $ documentationMenuItem -> getChildren ( ) ) { \ MoufAdmin :: getInstanceMenu ( ) -> addChild ( $ documentationMenuItem ) ; } } //\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>"); $ this -> displayComponentParents ( ) ; }
This function initiates the class variables of the controller according to the parameters passed.
It will also configure the template to have the correct entry, especially in the right menu thazt is context dependent.


@param string $name the name of the component to display
@param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
This function initiates the class variables of the controller according to the parameters passed . It will also configure the template to have the correct entry especially in the right menu thazt is context dependent .