Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /pattemplate/patTemplate/Function/Call.php

Documentation is available at Call.php

  1. <?PHP
  2. /**
  3.  * patTemplate function that enables you to insert any
  4.  * template, that has been loaded previously into the
  5.  * current template.
  6.  *
  7.  * You may pass any variables to the template.
  8.  *
  9.  * $Id: Call.php 321 2004-10-28 15:41:57Z schst $
  10.  *
  11.  * @package        patTemplate
  12.  * @subpackage    Functions
  13.  * @author        Stephan Schmidt <[email protected]>
  14.  */
  15.  
  16. // Check to ensure this file is within the rest of the framework
  17. defined('JPATH_BASE'or die();
  18.  
  19. /**
  20.  * template does not exist
  21.  */
  22. define'PATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE''patTemplate::Function::Call::NT' );
  23.  
  24. /**
  25.  * patTemplate function that enables you to insert any
  26.  * template, that has been loaded previously into the
  27.  * current template.
  28.  *
  29.  * You may pass any variables to the template.
  30.  *
  31.  * $Id: Call.php 321 2004-10-28 15:41:57Z schst $
  32.  *
  33.  * @package        patTemplate
  34.  * @subpackage    Functions
  35.  * @author        Stephan Schmidt <[email protected]>
  36.  */
  37. {
  38.    /**
  39.     * name of the function
  40.     * @access    private
  41.     * @var        string 
  42.     */
  43.     var $_name    =    'Call';
  44.  
  45.    /**
  46.     * reference to the patTemplate object that instantiated the module
  47.     *
  48.     * @access    protected
  49.     * @var    object 
  50.     */
  51.     var    $_tmpl;
  52.  
  53.    /**
  54.     * set a reference to the patTemplate object that instantiated the reader
  55.     *
  56.     * @access    public
  57.     * @param    object        patTemplate object
  58.     */
  59.     function setTemplateReference&$tmpl )
  60.     {
  61.         $this->_tmpl = &$tmpl;
  62.     }
  63.  
  64.    /**
  65.     * call the function
  66.     *
  67.     * @access    public
  68.     * @param    array    parameters of the function (= attributes of the tag)
  69.     * @param    string    content of the tag
  70.     * @return    string    content to insert into the template
  71.     */
  72.     function call$params$content )
  73.     {
  74.         // get the name of the template to use
  75.         if (isset($params['template'])) {
  76.             $tmpl $params['template'];
  77.             unset$params['template');
  78.         elseif (isset($params['_originalTag'])) {
  79.             $tmpl $params['_originalTag'];
  80.             unset$params['_originalTag');
  81.         else {
  82.             return patErrorManager::raiseErrorPATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE'No template for Call function specified.' );
  83.         }
  84.  
  85.         if (!$this->_tmpl->exists$tmpl )) {
  86.  
  87.             $tmpl strtolower($tmpl);
  88.  
  89.             // try some autoloading magic
  90.             $componentLocation  $this->_tmpl->getOption('componentFolder');
  91.             $componentExtension $this->_tmpl->getOption('componentExtension');
  92.             $filename $componentLocation '/' $tmpl '.' $componentExtension;
  93.             $this->_tmpl->readTemplatesFromInput($filename);
  94.  
  95.             // still does not exist
  96.             if!$this->_tmpl->exists$tmpl ) ) {
  97.                 return patErrorManager::raiseErrorPATTEMPLATE_FUNCTION_CALL_ERROR_NO_TEMPLATE'Template '.$tmpl.' does not exist' );
  98.             }
  99.         }
  100.  
  101.         /**
  102.          * clear template and all of its dependencies
  103.          */
  104.         $this->_tmpl->clearTemplate$tmpltrue );
  105.  
  106.         /**
  107.          * add variables
  108.          */
  109.         $this->_tmpl->addVars$tmpl$params );
  110.         $this->_tmpl->addVar$tmpl'CONTENT'$content );
  111.  
  112.         /**
  113.          * get content
  114.          */
  115.         return $this->_tmpl->getParsedTemplate$tmpl );
  116.     }
  117. }
  118. ?>

Documentation generated on Mon, 05 Mar 2007 20:53:44 +0000 by phpDocumentor 1.3.1