Location: PHPKode > projects > SkullPuppy > Project/library/SP/View.php
<?php

class SP_View extends SP_Base {
	protected $_config = array(
		'path' => 'application/views/scripts/',
		'ext' => 'php',
		'script' => 'index/index'
	);

	public function render() {
		$file = SP_Base_Dir.$this->_config['path'] . $this->_config['script'] .'.'. $this->getConfig('ext');
		if(!is_file($file)) throw new SP_Exception('View file does not exist ['.
			//$this->_config['path'] .
			$this->_config['script'].']');
		ob_start();
		if(!@include($file)) {
			throw new SP_Exception('Unable to open view file ['.$this->_config['script'].']');
		}
		$contents = ob_get_clean();
		return $contents;
	}

	public function __call($method, $args) {
		$class = ucfirst($method);
		$depth = explode('/',$this->_config['path']);
		if(!end($depth)) array_pop($depth);
		$depth = end($depth);
		$depth = ($depth=='layouts' ?
				'../../' : '../');
		$file = SP_Base_Dir.$this->_config['path'].$depth.'helpers/'.$class.'.'.
				$this->getConfig('ext');
		if(!class_exists("Helper_$class", false) && !@include($file)) {
			throw new SP_Exception("Invalid view helper [$class]");
		}
		$class = 'Helper_'.$class;
		if(method_exists($class,$method)) {
			$class = new $class();
			$class->view =& $this;
			return call_user_func_array(array($class,$method), $args);
		} else throw new SP_Exception("Invalid helper construction [$class]");
	}

	public function getHelper() {
		// TODO Finish getHelper code
	}

	public function url($params, $route=null) {
		$params = (array) $params;
		$module = $this->getConfig('controller')->moduleName();
		if($module && !$params['module']) $params['module'] = $module;
		return SP_HTTP::url($params, $route);
	}
	
	public function setScript($script) {
		$this->setConfig('script', $script);
	}
	
	public function getScript() {
		$this->getConfig('script');
	}
}

?>
Return current item: SkullPuppy