cvs: pear /HTML_Template_Xipe/Xipe/Filter TagLib.php

From: Date: Tue, 01 Apr 2003 12:54:11 +0000
Subject: cvs: pear /HTML_Template_Xipe/Xipe/Filter TagLib.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9696@lists.php.net to get a copy of this message
cain Tue Apr 1 07:54:11 2003 EDT Modified files: /pear/HTML_Template_Xipe/Xipe/Filter TagLib.php Log: - add {%endrepeat%} Index: pear/HTML_Template_Xipe/Xipe/Filter/TagLib.php diff -u pear/HTML_Template_Xipe/Xipe/Filter/TagLib.php:1.19 pear/HTML_Template_Xipe/Xipe/Filter/TagLib.php:1.20 --- pear/HTML_Template_Xipe/Xipe/Filter/TagLib.php:1.19 Fri Jan 31 22:36:54 2003 +++ pear/HTML_Template_Xipe/Xipe/Filter/TagLib.php Tue Apr 1 07:54:11 2003 @@ -15,7 +15,7 @@ // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ -// $Id: TagLib.php,v 1.19 2003/02/01 03:36:54 cain Exp $ +// $Id: TagLib.php,v 1.20 2003/04/01 12:54:11 cain Exp $ // require_once 'HTML/Template/Xipe/Options.php'; @@ -145,38 +145,47 @@ */ function repeat( $input ) { + $openDel = preg_quote($this->getOption('delimiter',0)); + $closeDel = preg_quote($this->getOption('delimiter',1)); + $_openDel = $this->getOption('delimiter',0); + $_closeDel = $this->getOption('delimiter',1); + // find those repeats which dont have no variable that is given as the loop variable // we need to do this, since the next regExp needs this variable name, because // we can not use the $5 to check if it is given (down there in the second regExp)... bummer $counterName = '$_someUniqueVariableName'; // generate something here - $input = preg_replace( '/'.preg_quote($this->options['delimiter'][0]). - '%\s*repeat\s+([^\s%]+)([^\$]*)%'.preg_quote($this->options['delimiter'][1]). + $input = preg_replace( '/'.$openDel. + '%\s*repeat\s+([^\s%]+)([^\$]*)%'.$closeDel. '/', //"PRE-REPEAT:<br>1='$1'<br>2='$2'<br>3='$3'<br>4='$4'<br>5='$5'<br>" , // for testing - $this->options['delimiter'][0]. + $_openDel. "%repeat $1 $counterName%". - $this->options['delimiter'][1], + $_closeDel, $input); $input = preg_replace( '/\n(.*)'. // save the indention in $1 - preg_quote($this->options['delimiter'][0]). + $openDel. '%\s*repeat\s+'. // find begin delimiter repeat at least one space behind and variable spaces before '([^\s]+)'. // find everything until the next space, which is the count variable $2 '(([^\$%]*)?(\$[^\s]+)?)?'. // find the loop varibale name $5, a lot of stuff around it is optional (?) // the variable name has to start with a $ and spaces are excluded, so we trim it too '\s*%'. // optional numbner of spaces before closing delimiter - preg_quote($this->options['delimiter'][1]). + $closeDel. '/', - "\n$1".$this->options['delimiter'][0]. + "\n$1".$_openDel. "for($5=0;$5<$2;$5++)". - $this->options['delimiter'][1], + $_closeDel, //"REPEAT:<br>1='$1'<br>2='$2'<br>3='$3'<br>4='$4'<br>5='$5'<br>6='$6'<br>" , // for testing $input); // replace unnecessary spaces, so the next regexp is shorter and easier + // if someone has autoBraces on and uses this.... well that would be a user-mistake, or a missing doc :-) + $regExp = '/[^\\\]'.$openDel.'%\s*endrepeat\s*%'.$closeDel.'/Ui'; + $input = preg_replace( $regExp , $_openDel.' \\} '.$_closeDel , $input ); + return $input; /* TESTS

« previous php.pear.cvs (#9696) next »