Source for file PHP.php
Documentation is available at PHP.php
// +---------------------------------------------------------------------------+
// | PEAR :: XML :: Transformer :: PHP Namespace Handler |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> and |
// +---------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +---------------------------------------------------------------------------+
require_once 'XML/Transformer/Namespace.php';
* Handler for the PHP Namespace.
* require_once 'XML/Transformer_OutputBuffer.php';
* require_once 'XML/Transformer/Namespace/PHP.php';
* $t = new XML_Transformer_OutputBuffer;
* $t->overloadNamespace('php', new XML_Transformer_Namespace_PHP);
* <dd>Current time: <php:expr>time()</php:expr></dd>
* <php:setvariable name="foo">bar</php:setvariable>
* <dd>foo = <php:getvariable name="foo"/></dd>
* <php:namespace name="my">
* <php:define name="tag">
* <h1 align="$align">$content</h1>
* <my:tag align="center">Some Text</my:tag>
* <dd>Current time: 1032158587</dd>
* <h1 align="center">Some Text</h1>
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
* @package XML_Transformer
var $_namespace = 'define';
var $_inNamespace = FALSE;
var $_namespaceClassDefinition = '';
// {{{ function start_define($attributes)
if ($this->_inNamespace) {
$this->_defineName = $attributes['name'];
// {{{ function end_define($cdata)
if (!$this->_inNamespace)
$this->_namespaceClassDefinition .= sprintf('
var $%s_attributes = array();
function start_%s($att) {
$this->%s_attributes = $att;
function end_%s($content) {
foreach ($this->%s_attributes as $__k => $__v) {
// {{{ function start_namespace($attributes)
$this->_inNamespace = TRUE;
$this->_namespace = $attributes['name'];
$classname = 'PEAR_XML_TRANSFORMER_NAMESPACE_PHP_' . $this->_namespace;
$this->_namespaceClassDefinition = sprintf(
'class %s extends XML_Transformer_Namespace {',
// {{{ function end_namespace($cdata)
$classname = 'PEAR_XML_TRANSFORMER_NAMESPACE_PHP_' . $this->_namespace;
eval ($this->_namespaceClassDefinition . ' };');
$this->_namespaceClassDefinition = '';
$this->_transformer->overloadNamespace (
$this->_inNamespace = FALSE;
// {{{ function start_expr($attributes)
// {{{ function end_expr($cdata)
return eval ('return ' . $cdata . ';');
// {{{ function start_logic($attributes)
// {{{ function end_logic($cdata)
// This does not actually work in PHP 4.2.3,
// when using XML_Transformer_OutputBuffer.
// {{{ function start_getparameter($attributes)
return isset ($_GET[$attributes['name']]) ? $_GET[$attributes['name']] : '';
// {{{ function end_getparameter($cdata)
// {{{ function start_postparameter($attributes)
return isset ($_POST[$attributes['name']]) ? $_POST[$attributes['name']] : '';
// {{{ function end_postparameter($cdata)
// {{{ function start_cookievariable($attributes)
return isset ($_COOKIE[$attributes['name']]) ? $_COOKIE[$attributes['name']] : '';
// {{{ function end_cookievariable($cdata)
// {{{ function start_servervariable($attributes)
return isset ($_SERVER[$attributes['name']]) ? $_SERVER[$attributes['name']] : '';
// {{{ function end_servervariable($cdata)
// {{{ function start_sessionvariable($attributes)
return isset ($_SESSION[$attributes['name']]) ? $_SESSION[$attributes['name']] : '';
// {{{ function end_sessionvariable($cdata)
// {{{ function start_getvariable($attributes)
return isset ($GLOBALS[$attributes['name']]) ? $GLOBALS[$attributes['name']] : '';
// {{{ function end_getvariable($cdata)
// {{{ function start_setvariable($attributes)
$this->_variable = isset ($attributes['name']) ? $attributes['name'] : '';
// {{{ function end_setvariable($cdata)
if ($this->_variable != '') {
$GLOBALS[$this->_variable] = $cdata;
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 15:48:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|