cvs: pear /HTML_TINX TINX.php
| From: | Sebastian Bergmann | Date: | Tue, 08 Jan 2002 18:11:54 +0000 |
| Subject: | cvs: pear /HTML_TINX TINX.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1870@lists.php.net to get a copy of this message | ||
sebastian Tue Jan 8 13:11:54 2002 EDT
Modified files:
/pear/HTML_TINX TINX.php
Log:
Remove global parameter substituition. This does not fit with the upcoming <php:expr> and
<php:logic> tags.
Index: pear/HTML_TINX/TINX.php
diff -u pear/HTML_TINX/TINX.php:1.5 pear/HTML_TINX/TINX.php:1.6
--- pear/HTML_TINX/TINX.php:1.5 Tue Jan 8 08:13:00 2002
+++ pear/HTML_TINX/TINX.php Tue Jan 8 13:11:54 2002
@@ -16,7 +16,7 @@
// | Author: Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: TINX.php,v 1.5 2002/01/08 13:13:00 sebastian Exp $
+// $Id: TINX.php,v 1.6 2002/01/08 18:11:54 sebastian Exp $
//
/**
@@ -34,10 +34,11 @@
* <?php
* require 'HTML/TINX.php';
*
+* $bar = 'php variable';
+*
* $t = new HTML_TINX('test.xml', true, true);
-* $t->set_var('foo', 'test');
+* $t->set_var('foo', 'template variable');
*
-* $bar = 'test';
* echo '<pre>' . htmlspecialchars($t->parse()) . '</pre>';
*
* function foobar($a, $b) {
@@ -48,17 +49,17 @@
* test.xml
*
* <foo>{foo}</foo>
-* <bar>{bar}</bar>
+* <bar><php:expr>$bar</php:expr></foo>
* <foobar><php:foobar parameters="value1,value2" /></foobar>
*
* Output
*
-* <foo>test</foo>
-* <bar>test</bar>
+* <foo>template variable</foo>
+* <bar>php variable</bar>
* <foobar>foobar(value1, value2) called.</foobar>
*
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
-* @version $Revision: 1.5 $
+* @version $Revision: 1.6 $
* @access public
*/
@@ -96,16 +97,9 @@
* @access private
*/
- var $_replace_global_variables;
-
- /**
- * @var boolean
- * @access private
- */
-
- var $_execute_processing_instructions;
+ var $_execute_tag_logic;
- // {{{ function HTML_TINX($file = '', $replace_global_variables = false,
$execute_processing_instructions = false, $template_variable_delimiters = array('{',
'}')) {
+ // {{{ function HTML_TINX($file = '', $execute_tag_logic = false,
$template_variable_delimiters = array('{', '}')) {
/**
* Constructor
@@ -117,13 +111,9 @@
* @access public
*/
- function HTML_TINX($file = '', $replace_global_variables = false,
$execute_processing_instructions = false, $template_variable_delimiters = array('{',
'}')) {
+ function HTML_TINX($file = '', $execute_tag_logic = false,
$template_variable_delimiters = array('{', '}')) {
$this->setFile($file);
-
- $this->setParseParameters($replace_global_variables,
- $execute_processing_instructions
- );
-
+ $this->setParseParameters($execute_tag_logic);
$this->setTemplateVariableDelimiters($template_variable_delimiters);
}
@@ -167,7 +157,7 @@
}
// }}}
- // {{{ function setParseParameters($replace_global_variables, $execute_processing_instructions)
+ // {{{ function setParseParameters($execute_tag_logic)
/**
*
@@ -177,9 +167,8 @@
* @access public
*/
- function setParseParameters($replace_global_variables, $execute_processing_instructions) {
- $this->_replace_global_variables = $replace_global_variables;
- $this->_execute_processing_instructions = $execute_processing_instructions;
+ function setParseParameters($execute_tag_logic) {
+ $this->_execute_tag_logic = $execute_tag_logic;
}
// }}}
@@ -222,9 +211,16 @@
function parse() {
if (!empty($this->_template)) {
- // Execute <php:foo ... /> processing instructions.
+ // <php:expr>$bar</php:expr>
+ // <php:logic>echo date("F j, Y, g:i a");</php:logic>
+
+ // ...
- if ($this->_execute_processing_instructions) {
+ // <php:foo::bar parameters="param1,param2" />
+ // <php:foo->bar parameters="param1,param2" />
+ // <php:foobar parameters="param1,param2" />
+
+ if ($this->_execute_tag_logic) {
preg_match_all('/\<php:([^>]+)\/\>/im',
$this->_template,
$processing_instructions
@@ -271,21 +267,6 @@
);
} else {
$parsed_template = $this->_template;
- }
-
- // Replace {foo} template variables, that have not
- // been taken care of in the previous step, with
- // global variables of the same name.
-
- if ($this->_replace_global_variables) {
- $parsed_template = preg_replace('/' .
-
preg_quote($this->_template_variable_delimiters[0]) .
- '([^]]+)' .
-
preg_quote($this->_template_variable_delimiters[1]) .
- '/ime',
- 'isset($GLOBALS[\'\\1\']) ?
$GLOBALS[\'\\1\'] : \'\'',
- $parsed_template
- );
}
return $parsed_template;