CoreFiles by mySites.guru
Call.php119 lines, 2,974 bytes, from Joomla_1.5.4-Stable-Full_Package.zip
Raw History Compare with 1.5.3
md5
7220172ce5539e5ecfe7c251e549e89c
sha1
4d6225983154f8435104a298c80729def8a4f566
sha256
c253d97b771b2d1c16bbda730c4b6f38e26f7fd0be66cb65224a8eb261149965
<?PHP
/**
 * patTemplate function that enables you to insert any
 * template, that has been loaded previously into the
 * current template.
 *
 * You may pass any variables to the template.
 *
 * $Id: Call.php 10381 2008-06-01 03:35:53Z pasamio $
 *
 * @package		patTemplate
 * @subpackage	Functions
 * @author		Stephan Schmidt <[email protected]>
 */

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * template does not exist
 */
define( 'PATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE', 'patTemplate::Function::Call::NT' );

/**
 * patTemplate function that enables you to insert any
 * template, that has been loaded previously into the
 * current template.
 *
 * You may pass any variables to the template.
 *
 * $Id: Call.php 10381 2008-06-01 03:35:53Z pasamio $
 *
 * @package		patTemplate
 * @subpackage	Functions
 * @author		Stephan Schmidt <[email protected]>
 */
class patTemplate_Function_Call extends patTemplate_Function
{
	/**
	* name of the function
	* @access	private
	* @var		string
	*/
	var $_name	=	'Call';

	/**
	* reference to the patTemplate object that instantiated the module
	*
	* @access	protected
	* @var	object
	*/
	var	$_tmpl;

	/**
	* set a reference to the patTemplate object that instantiated the reader
	*
	* @access	public
	* @param	object		patTemplate object
	*/
	function setTemplateReference( &$tmpl )
	{
		$this->_tmpl = &$tmpl;
	}

	/**
	* call the function
	*
	* @access	public
	* @param	array	parameters of the function (= attributes of the tag)
	* @param	string	content of the tag
	* @return	string	content to insert into the template
	*/
	function call( $params, $content )
	{
		// get the name of the template to use
		if (isset($params['template'])) {
			$tmpl = $params['template'];
			unset( $params['template'] );
		} elseif (isset($params['_originalTag'])) {
			$tmpl = $params['_originalTag'];
			unset( $params['_originalTag'] );
		} else {
			return patErrorManager::raiseError( PATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE, 'No template for Call function specified.' );
		}

		if (!$this->_tmpl->exists( $tmpl )) {

			$tmpl = strtolower($tmpl);

			// try some autoloading magic
			$componentLocation  = $this->_tmpl->getOption('componentFolder');
			$componentExtension = $this->_tmpl->getOption('componentExtension');
			$filename = $componentLocation . '/' . $tmpl . '.' . $componentExtension;
			$this->_tmpl->readTemplatesFromInput($filename);

			// still does not exist
			if( !$this->_tmpl->exists( $tmpl ) ) {
				return patErrorManager::raiseError( PATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE, 'Template '.$tmpl.' does not exist' );
			}
		}

		/**
		 * clear template and all of its dependencies
		 */
		$this->_tmpl->clearTemplate( $tmpl, true );

		/**
		 * add variables
		 */
		$this->_tmpl->addVars( $tmpl, $params );
		$this->_tmpl->addVar( $tmpl, 'CONTENT', $content );

		/**
		 * get content
		 */
		return $this->_tmpl->getParsedTemplate( $tmpl );
	}
}
?>

The same content is in 23 releases, Joomla 1.5.4 to 1.5.26. See them all, or every version of this file.