- md5
- 4c37caf3af6326aeb11ccfdec6d8605f
- sha1
- 6b0c33ea894991a72e4429dce65cf4f50879ac5a
- sha256
- 2aafed254cb790796b76300d56096c4322ab7e577a83a2cfbeed284236c1e43a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
<?PHP
/**
* Base class for patTemplate dumpers
*
* $Id: Dump.php 10381 2008-06-01 03:35:53Z pasamio $
*
* The dump functionality is separated from the main class
* for performance reasons.
*
* @package patTemplate
* @subpackage Dump
* @author Stephan Schmidt <[email protected]>
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* Base class for patTemplate dumpers
*
* The dump functionality is separated from the main class
* for performance reasons.
*
* @abstract
* @package patTemplate
* @subpackage Dump
* @author Stephan Schmidt <[email protected]>
*/
class patTemplate_Dump extends patTemplate_Module
{
/**
* 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;
}
/**
* display the header
*
* @access public
*/
function displayHeader()
{
}
/**
* dump the global variables
*
* @access public
* @param array array containing all global variables
* @abstract
*/
function dumpGlobals( $globals )
{
}
/**
* dump the templates
*
* This method has to be implemented in the dumpers.
*
* @access public
* @abstract
* @param array templates
* @param array variables
*/
function dumpTemplates( $templates, $vars )
{
}
/**
* display the footer
*
* @access public
*/
function displayFooter()
{
}
/**
* flatten the variables
*
* This will convert the variable definitions
* to a one-dimensional array. If there are
* rows defined, they will be converted to a string
* where the values are seperated with commas.
*
* @access private
* @param array variable definitions
* @return array flattened variables
*/
function _flattenVars( $vars )
{
$flatten = array();
foreach( $vars['scalar'] as $var => $value )
{
$flatten[$var] = $value;
}
foreach( $vars['rows'] as $row )
{
foreach( $row as $var => $value )
{
if( !isset( $flatten[$var] ) || !is_array( $flatten[$var] ) )
$flatten[$var] = array();
array_push( $flatten[$var], $value );
}
}
foreach( $flatten as $var => $value )
{
if( !is_array( $value ) )
continue;
$flatten[$var] = '['.count($value).' rows] ('.implode( ', ', $value ).')';
}
return $flatten;
}
/**
* extract all variables from a template
*
* @access private
* @param string template content
* @return array array containing all variables
*/
function _extractVars( $template )
{
$pattern = '/'.$this->_tmpl->getStartTag().'([^a-z]+)'.$this->_tmpl->getEndTag().'/U';
$matches = array();
$result = preg_match_all( $pattern, $template, $matches );
if( $result == false )
return array();
$vars = array();
foreach( $matches[1] as $var )
{
if( strncmp( $var, 'TMPL:', 5 ) === 0 )
continue;
array_push( $vars, $var );
}
return array_unique( $vars );
}
}
?>
The same content is in 23 releases, Joomla 1.5.4 to 1.5.26. See them all, or every version of this file.