Support Joomla!
Main
News
Help
Forum
Extensions
Shop
Developers
Joomla! 1.5 Documentation
Home
API reference wiki
Browse SVN repository
Packages
Select a package...
Unknown
Cache_Lite
com-tecnick-tcpdf
core
Joomla-Framework
OpenID
patError
patTemplate
PEAR
phpGACL
PHPMailer
PHP_Compat
utf8
Yadis
Package: patTemplate
Other documents
Changelog
To do
To do (2)
Element index (all)
Error log
Install
Copyright
License
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/Dump.php
Documentation is available at
Dump.php
<?PHP
/**
* Base class for patTemplate dumpers
*
* $Id: Dump.php 219 2004-05-25 20:38:38Z schst $
*
* 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
)
;
}
}
?>
Documentation generated on Mon, 05 Mar 2007 20:56:54 +0000 by
phpDocumentor 1.3.1