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

From: Date: Fri, 04 Apr 2003 18:16:31 +0000
Subject: cvs: pear /HTML_Template_Xipe/Xipe/Filter Basic.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9743@lists.php.net to get a copy of this message
cain Fri Apr 4 13:16:31 2003 EDT Modified files: /pear/HTML_Template_Xipe/Xipe/Filter Basic.php Log: - exclude ifBeforeForeach when autoBraces is off Index: pear/HTML_Template_Xipe/Xipe/Filter/Basic.php diff -u pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.19 pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.20 --- pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.19 Fri Jan 31 22:36:08 2003 +++ pear/HTML_Template_Xipe/Xipe/Filter/Basic.php Fri Apr 4 13:16:31 2003 @@ -15,7 +15,7 @@ // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ -// $Id: Basic.php,v 1.19 2003/02/01 03:36:08 cain Exp $ +// $Id: Basic.php,v 1.20 2003/04/04 18:16:31 cain Exp $ require_once 'HTML/Template/Xipe/Options.php'; @@ -309,18 +309,24 @@ */ function addIfBeforeForeach($input) { - return preg_replace('/\n(\s*)'. // get the indented spaces in $1, starting at the beginning of a line (^ didnt work here, at least not for me) - preg_quote($this->options['delimiter'][0]). - '\s*foreach\s*\('. // check for the '{foreach(' and spaces anywhere inbetween, '\s*' does that - '\s*'. // spaces after the '(' might be allowed - '(\$.*)'. // get the variable name in $2 - '\s'. // and search for the next space, since that means the variable name ended here - '/U', // and be greedy ... dont know why but we need it (i dont understand what greedy means anyway) - - "\n$1". - $this->options['delimiter'][0]. - "if(is_array(@$2) && sizeof(@$2)>0)foreach($2 ", - $input); + // this i.e. doesnt work with autoBraces off + // {if(...):} {foreach(...):}{endforeach}{else:}{endif} ... :-( + if ($this->getOption('autoBraces')==false) { + return $input; + } else { + return preg_replace('/\n(\s*)'. // get the indented spaces in $1, starting at the beginning of a line (^ didnt work here, at least not for me) + preg_quote($this->options['delimiter'][0]). + '\s*foreach\s*\('. // check for the '{foreach(' and spaces anywhere inbetween, '\s*' does that + '\s*'. // spaces after the '(' might be allowed + '(\$.*)'. // get the variable name in $2 + '\s'. // and search for the next space, since that means the variable name ended here + '/U', // and be greedy ... dont know why but we need it (i dont understand what greedy means anyway) + + "\n$1". + $this->options['delimiter'][0]. + "if(is_array(@$2) && sizeof(@$2)>0)foreach($2 ", + $input); + } } /**

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