Location: PHPKode > projects > Tv.2 CMS > tv2engine/pyramidSite.class.php
<?php

/** 
 * Abstract class for pyramid-framework site classes
 * 
 * @package pyramid-framework
 * @author Emilis Dambauskas (hide@address.com)
 * @copyright 2002–2003 Emilis Dambauskas under {@link http://opensource.org/licenses/artistic-license.php Artistic license}
 * @version $Id: pyramidSite.class.php,v 1.1 2003/07/05 09:46:53 lunaticlt Exp $
 * @class pyramidSite
 */
class pyramidSite
{
	/**
	 * A reference to global {@link $vs} object
	 * @attribute private object $vs
	 */
	var $vs;
	
	/**
	 * Method name used in $this->show()
	 * @attribute private string $method
	 */
	var $method;
	
	/**
	 * @constructor pyramidSite  
	 * @use $vs   
	 */ 
	function pyramidSite()
	{
		$this->vs = &$GLOBALS['vs'];
		$this->method = 'showPage';
	}
	
	/**
	 * Sets the value of $this->method which is used in $this->show()
	 * 
	 * @method public setMethod 
	 * @param string $method method name   
	 */  
	function setMethod($method)
	{
		$this->method = $method;
	}
	
	/**
	 * Takes $content and calls a method on itself
	 * 
	 * @method public show
	 * @return mixed Whatever the called method returns
	 * @param mixed $content Usually content of a page
	 */  
	function show($content)
	{
		if (!$this->method)
			$this->method = 'showPage';
		return call_user_func(array($this, $this->method), $content);
	}
	
	/**
	 * This method is needed when you output something from a module that you don't 
	 * want {@link $site} to modify
	 * 
	 * @method public passthru
	 * @return mixed Whatever $content is 
	 * @param mixed $content Data to pass through  
	 */  
	function passthru($content)
	{
		return $content;
	}
	
	/**
	 * You should rewrite this method in your classes to suit your needs. 
	 * Currently it takes $content, forces it to become array and uses it in 
	 * template page.tpl
	 * 
	 * @method public showPage
	 * @return string 
	 * @param mixed $content The content of the page  
	 */  
	function showPage($content)
	{
		if (!is_array($content))
			$content = array('html'=>$content);
		$this->vs->setVars($content);
		
		return $this->vs->process('page.tpl');
	}
	
	/**
	 * Shows site index page. You should rewrite this method in your classes to 
	 * suit your needs. Currently it outputs index.tpl
	 *
	 * @method public showIndex
	 * @return string Index page contents  
	 */  
	function showIndex()
	{
		return $this->vs->process('index.tpl');
	}
	
	/**
	 * Shows error message. One default error code is specified: 404 (page not found)
	 * 
	 * @method public showError
	 * @return string Error page 
	 * @param mixed $content Error code/message  
	 */  
	function showError($content)
	{
		if ($content == 404)
				$content = 'The page cannot be found.';
		
		if (!is_array($content))
			$content = array('msg'=>$content);
		
		$this->vs->setVars($content);
		return $this->vs->process('error.tpl');
	}
	
}
Return current item: Tv.2 CMS