Date: 03/30/00
- Next message: Kristian Köhntopp: "[PHPLIB-DEV] [Fwd: [PHP4BETA] XSL module in PHP4]"
- Previous message: Kristian Köhntopp: "Re: [PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: kir
Date: Thu Mar 30 16:58:27 2000
Modified files:
php-lib/CHANGES
php-lib/php/template.inc
Log message:
Undo my last changes.
Index: php-lib/CHANGES
diff -u php-lib/CHANGES:1.166 php-lib/CHANGES:1.167
--- php-lib/CHANGES:1.166 Thu Mar 30 15:42:35 2000
+++ php-lib/CHANGES Thu Mar 30 16:57:56 2000
@@ -1,45 +1,7 @@
-$Id: CHANGES,v 1.166 2000/03/30 13:42:35 kir Exp $
+$Id: CHANGES,v 1.167 2000/03/30 14:57:56 kir Exp $
30-Mar-2000 kir
- - More story about templates. Now Template class from template.inc
- supports conditional blocks:
- <!-- BEGIN var IF {expression} --> {another_var} html code
- <!-- END var -->
- So you can define IF-ed blocks. This feature works in loops too.
- Sorry, I know nothing about sgml and my english too poor to update
- documentation :(.
-
- An Example:
- -------------- template.ihtml -----------------
- <TABLE>
- <!-- BEGIN loop -->
-
- <TR><TD>Name: {name}<BR>
- <!-- BEGIN email_if IF {email_test} -->
- Email: {email}
- <!-- END email_if-->
- </TD>
- <!-- END loop -->
- </TABLE>
- -----------------------------------------------
- // Appropriate code:
- $t = new Template(...);
- $t->set_file("fl","template.ihtml");
- $t->set_block("fl", "loop", "loop_handle");
- $t->set_block("loop", "email_if", "email_handle");
-
- while ( has_more_data )
- {
- // here we get $name, $email
- // $email may be empty
- $t->set_var("name", $name);
- $t->set_var("email", $email);
- $t->set_var("email_test", !empty($email));
-
- $t->parse("email_handle", "email_if", false);
- $t->parse("loop_handle", "loop", true);
- }
-
+ - Add and remove conditional templates feature ;-o
29-Mar-2000 kir
- Make Tmpl_Control::set_file() compatible with Template::set_file()
Index: php-lib/php/template.inc
diff -u php-lib/php/template.inc:1.15 php-lib/php/template.inc:1.16
--- php-lib/php/template.inc:1.15 Thu Mar 30 15:47:30 2000
+++ php-lib/php/template.inc Thu Mar 30 16:57:57 2000
@@ -5,7 +5,7 @@
* (C) Copyright 1999 NetUSE GmbH
* Kristian Koehntopp
*
- * $Id: template.inc,v 1.15 2000/03/30 13:47:30 kir Exp $
+ * $Id: template.inc,v 1.16 2000/03/30 14:57:57 kir Exp $
*
*/
@@ -168,20 +168,6 @@
function subst($varname) {
$str = $this->get_var($varname);
$str = <email protected>($this->varkeys, $this->varvals, $str);
-
- if (!empty($this->block[$varname]["extra"]))
- {
- $evalstr = <email protected>($this->varkeys, $this->varvals,
- $this->block[$varname]["extra"]);
- // echo "IF $varname, $beforeeval, $evalstr";
- $flag=0;
- eval("\$flag=$evalstr;");
- if (!$flag)
- {
- $str="";
- }
- }
-
return $str;
}
@@ -400,19 +386,11 @@
/* get parent variable */
$str = $this->get_var($parent);
- //print "\n\n$varname $parent $alias ".$str;
-
/* find the subblock we are looking for and extract it */
$reg = "/<!--\\s+BEGIN $varname\\s+-->(.*)<!--\\s+END $varname\\s+-->/sm";
if (!preg_match_all($reg, $str, $m))
{
- $reg = "/<!--\\s+BEGIN $varname\\s+IF\\s+(.*?)\\s*-->(.*)<!--\\s+END $varname\\s+-->/sm";
- if (!preg_match_all($reg, $str, $m))
- {
- $this->halt("implode_block - no match for $varname variable");
- }
- $this->block[$varname]["extra"] = $m[1][0];
- $m[1][0] = $m[2][0];
+ $this->halt("implode_block - no match for $varname variable");
}
/* implode the subblock to the requested alias */
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: Kristian Köhntopp: "[PHPLIB-DEV] [Fwd: [PHP4BETA] XSL module in PHP4]"
- Previous message: Kristian Köhntopp: "Re: [PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

