Location: PHPKode > projects > ArasPhp Framework > ArasPhp-0.03/core/actions/RenderView.php
<?php

/**
 * Renders the view
 */
 
 /*
 * CASE 1: Errors happen during the controller proccess
 *
 * 1) Check for valid ERROR_REDIRECT
 * 2) Load the view error
 * 3) Redirect to ERROR_REDIRECT if is valid
 */
  
 if($errors != NULL)
 {
	
	// First we will check that ERROR_REDIRECT set up in config file is valid and exists
 	if(ERROR_REDIRECT != NULL)
 	{
 		$dispatcherHelper = new Dispatcher(ERROR_REDIRECT);
 		
 		// If valid redirection controller/view
 		if($dispatcherHelper->getErrors() == NULL)
 		{
 			$redirect = true;
 			unset($dispatcherHelper);
 			
 		} else {
 		
 			$errors[] = "The error redirect controller specified in the /config/config.php file is not valid.";
 		
 		}
 		
 	} else {
 	
 		// redirect controller is null, the user might want to set one up
 		$errors[] = "You might want to specify an error redirect controller in /config/config.php";
 	
 	}
 
 	// We include error view
 	include(VIEW . "messages/error.php");
 	
 	// And redirect if needed
 	if($redirect == true)
 	{
 		Core::requestAction(ERROR_REDIRECT);
 	}
 	
 
  /*
 * CASE 2: Errors happen during the controller proccess
 *
 * 1) Check for flash or dataError messages
 * 2) Check for a forced view load
 *	> If it does not exist, error
 * 3) Load the view
 */
 	
	
 } else {
 
 	// If flash message exist, we load the displayer
 	if($flash != NULL)
 	{
 		include(VIEW . "messages/flash.php");
 	}
 	
 	// Si validation errors exists, we load the displayer
 	if($dataErrors != NULL)
 	{
 		include(VIEW . "messages/dataError.php");
 	}
 	
 	/*
 	* If the user forced a view to be loaded in the controller
 	*/
 	
 	if(isset($setView))
 	{
 		// Check if it does not exists
 		if(!file_exists($setView))
 		{
 			// Then we add a nice error message
 			$errors[] = "The view you manually set up to load does not exist. ($setView)";
 			
 			// And include error view
 			include(VIEW . "messages/error.php");
 			
 		} else {
 		
 			// It exists. We load it.
 			include($setView);
 		}
 		
 	/*
 	* If not, we just load the associated one
 	*/
 		
 	} else {
 	
 		include($dispatcher->getView());
 		
 	}
 
 }

?>
Return current item: ArasPhp Framework