protected function _fetchTemplate($params = array())
	{
		// Check
		$directory = isset($params['directory']) ? $params['directory'] : PATH_CORE . '/templates';

		$template = isset($params['template']) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['template']) : 'system';
		$file     = isset($params['file'])     ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['file'])     : 'index.php';

		if (!file_exists($directory . DS . $template . DS . $file))
		{
			$directory = PATH_CORE . '/templates';
			$template  = 'system';
			$params['baseurl'] = str_replace('/app', '/core', $params['baseurl']);
		}

		// Load the language file for the template
		$lang = \App::get('language');
		$lang->load('tpl_' . $template, PATH_APP . DS . 'bootstrap' . DS . \App::get('client')->name, null, false, true) ||
		$lang->load('tpl_' . $template, $directory . DS . $template, null, false, true);

		// Assign the variables
		$this->template = $template;
		//$this->path     = (isset($params['path']) ? $params['path'] : rtrim(\Request::root(true), '/')) . '/templates/' . $template;
		//$this->baseurl  = rtrim(\Request::root(true), '/');
		$this->baseurl  = isset($params['baseurl']) ? $params['baseurl'] : rtrim(\Request::root(true), '/');
		$this->params   = isset($params['params'])  ? $params['params']  : new Registry;

		// Load
		$this->_template = $this->_loadTemplate($directory . DS . $template, $file);

		return $this;
	}
protected function _fetchTemplate($params = array())
	{
		// Check
		$directory = isset($params['directory']) ? $params['directory'] : PATH_CORE . '/templates';

		$template = isset($params['template']) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['template']) : 'system';
		$file     = isset($params['file'])     ? preg_replace('/[^A-Z0-9_\.-]/i', '', $params['file'])     : 'index.php';

		if (!file_exists($directory . DS . $template . DS . $file))
		{
			$directory = PATH_CORE . '/templates';
			$template  = 'system';
			$params['baseurl'] = str_replace('/app', '/core', $params['baseurl']);
		}

		// Load the language file for the template
		$lang = \App::get('language');
		$lang->load('tpl_' . $template, PATH_APP . DS . 'bootstrap' . DS . \App::get('client')->name, null, false, true) ||
		$lang->load('tpl_' . $template, $directory . DS . $template, null, false, true);

		// Assign the variables
		$this->template = $template;
		//$this->path     = (isset($params['path']) ? $params['path'] : rtrim(\Request::root(true), '/')) . '/templates/' . $template;
		//$this->baseurl  = rtrim(\Request::root(true), '/');
		$this->baseurl  = isset($params['baseurl']) ? $params['baseurl'] : rtrim(\Request::root(true), '/');
		$this->params   = isset($params['params'])  ? $params['params']  : new Registry;

		// Load
		$this->_template = $this->_loadTemplate($directory . DS . $template, $file);

		return $this;
	}
protected function _fetchTemplate ( $ params = array ( ) ) { // Check $ directory = isset ( $ params [ 'directory' ] ) ? $ params [ 'directory' ] : PATH_CORE . '/templates' ; $ template = isset ( $ params [ 'template' ] ) ? preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ params [ 'template' ] ) : 'system' ; $ file = isset ( $ params [ 'file' ] ) ? preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ params [ 'file' ] ) : 'index.php' ; if ( ! file_exists ( $ directory . DS . $ template . DS . $ file ) ) { $ directory = PATH_CORE . '/templates' ; $ template = 'system' ; $ params [ 'baseurl' ] = str_replace ( '/app' , '/core' , $ params [ 'baseurl' ] ) ; } // Load the language file for the template $ lang = \ App :: get ( 'language' ) ; $ lang -> load ( 'tpl_' . $ template , PATH_APP . DS . 'bootstrap' . DS . \ App :: get ( 'client' ) -> name , null , false , true ) || $ lang -> load ( 'tpl_' . $ template , $ directory . DS . $ template , null , false , true ) ; // Assign the variables $ this -> template = $ template ; //$this->path     = (isset($params['path']) ? $params['path'] : rtrim(\Request::root(true), '/')) . '/templates/' . $template; //$this->baseurl  = rtrim(\Request::root(true), '/'); $ this -> baseurl = isset ( $ params [ 'baseurl' ] ) ? $ params [ 'baseurl' ] : rtrim ( \ Request :: root ( true ) , '/' ) ; $ this -> params = isset ( $ params [ 'params' ] ) ? $ params [ 'params' ] : new Registry ; // Load $ this -> _template = $ this -> _loadTemplate ( $ directory . DS . $ template , $ file ) ; return $ this ; }
Fetch the template, and initialise the params

@param   array   $params  Parameters to determine the template
@return  object  instance of $this to allow chaining
Fetch the template and initialise the params