<?php
/**
 * @version: $Id: template_php.php 3149 2013-02-15 16:26:23Z Radek Suski $
 * @package: SobiPro Library

 * @author
 * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
 * Email: sobi[at]sigsiu.net
 * Url: http://www.Sigsiu.NET

 * @copyright Copyright (C) 2006 - 2013 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
 * @license GNU/LGPL Version 3
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
 * See http://www.gnu.org/licenses/lgpl.html and http://sobipro.sigsiu.net/licenses.

 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

 * $Date: 2013-02-15 17:26:23 +0100 (Fri, 15 Feb 2013) $
 * $Revision: 3149 $
 * $Author: Radek Suski $
 * $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Site/lib/mlo/template_php.php $
 */

defined( 'SOBIPRO' ) || exit( 'Restricted access' );

SPLoader::loadClass( 'mlo.template');

/**
 * @author Radek Suski
 * @version 1.0
 * @created 28-Oct-2009 09:08:04 AM
 */
class SPTemplatePHP implements SPTemplate
{
	/**
	 * @var SPFrontView
	 */
	private $_proxy = null;
	/**
	 * @var array
	 */
	private $_data = null;
	/**
	 * @var string
	 */
	private $_tpl = null;
	/**
	 * @var string
	 */
	private $_type = 'root';
	/**
	 * @var DOMDocument
	 */
	private $_xml = null;

	public function display()
	{
		$template = SPLoader::loadTemplate( $this->_tpl, 'php' );
		if( $template ) {
			include( $template );
		}
		else {
			throw new SPException( SPLang::e( 'CANNOT_LOAD_TEMPLATE_FILE_AT', SPLoader::loadTemplate( $this->_tpl, 'php', false ) ) );
		}
	}

	/**
	 * @param string $type the listing type to set
	 */
	public function setType( $type )
	{
		$this->_type = $type;
	}

	/** (non-PHPdoc)
	 * @var SPFrontView $proxy
	 * @see Site/lib/mlo/SPTemplate#setProxy()
	 */
	public function setProxy( &$proxy )
	{
		$this->_proxy =& $proxy;
	}

	/** (non-PHPdoc)
	 * @var array $data
	 * @see Site/lib/mlo/SPTemplate#setData()
	 */
	public function setData( $data )
	{
		$this->_data =& $data;
	}

	/** (non-PHPdoc)
	 * @var string $template
	 * @see Site/lib/mlo/SPTemplate#setTemplate()
	 */
	public function setTemplate( $template )
	{
		$this->_tpl = $template;
	}

	/**
	 * @param string $method
	 * @param array $params
	 * @return mixed
	 */
	public function __call( $method, $params )
	{
		return call_user_func_array( array( $this->_proxy, $method ), $params );
	}
}
