cvs: pear /HTML_Template_Xipe/Xipe/Filter Basic.php
| From: | Wolfram Kriesing | Date: | Sat, 01 Feb 2003 03:36:08 +0000 |
| Subject: | cvs: pear /HTML_Template_Xipe/Xipe/Filter Basic.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8620@lists.php.net to get a copy of this message | ||
cain Fri Jan 31 22:36:08 2003 EDT
Modified files:
/pear/HTML_Template_Xipe/Xipe/Filter Basic.php
Log:
- made addIfBeforeForeach work with autoBraces OFF too
Index: pear/HTML_Template_Xipe/Xipe/Filter/Basic.php
diff -u pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.18
pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.19
--- pear/HTML_Template_Xipe/Xipe/Filter/Basic.php:1.18 Sat Jan 18 10:28:12 2003
+++ pear/HTML_Template_Xipe/Xipe/Filter/Basic.php Fri Jan 31 22:36:08 2003
@@ -15,7 +15,7 @@
// +----------------------------------------------------------------------+
// | Authors: Wolfram Kriesing <wolfram@kriesing.de> |
// +----------------------------------------------------------------------+
-// $Id: Basic.php,v 1.18 2003/01/18 15:28:12 cain Exp $
+// $Id: Basic.php,v 1.19 2003/02/01 03:36:08 cain Exp $
require_once 'HTML/Template/Xipe/Options.php';
@@ -82,7 +82,7 @@
$input = $this->removeEmptyLines($input);
$input = $this->trimLines($input);
$input = $this->optimizeHtmlCode($input);
- }
+ }
// this is default since, it enables you to also use 'switch case' blocks
// if we wouldnt optimize the php here then there would be spaces printed between switch
and case
// which php doesnt allow! (only with autoBraces of course)
@@ -281,20 +281,22 @@
* so i dont have to make this check in every place myself (since i mostly need the
* check anyway or PHP will freak if $x is an empty array)
* its just the same as "show a block only if it really contains data"
- * use as a PRE filter, works only if autoBraces is used and indention of at least 2
characters
- * out of this:
+ * use as a PRE filter
+ * out of this:
+ *
* {foreach($x as $oneX)}
* {$oneX}
* {else}
* no x's available
+ *
* it makes
- * {if(sizeof($x))}
- * {foreach($x as $oneX)}
+ *
+ * {if(sizeof($x))foreach($x as $oneX)}
* {$oneX}
* {else}
* no x's available
- * NOTE: that you can also use {else} on a 'foreach', because it will then be used
for
- * the 'if' because the 'foreach' gets indented on more space
+ *
+ * NOTE: that you can also use {else} on a 'foreach', because it will then be used
for the 'if'
* NOTE1: this filter can only be applied if the delimiters are not set via the xml
* options inside the file, this doesnt work yet ... :-(
* since the xml data change the delimiter, which was passed to the constructor when
@@ -307,10 +309,6 @@
*/
function addIfBeforeForeach($input)
{
- // the filter below only works if autoBraces is on!
- if( !$this->getOption('autoBraces') )
- return $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
@@ -321,12 +319,7 @@
"\n$1".
$this->options['delimiter'][0].
- "if(is_array(@$2) && sizeof(@$2)>0)".
- $this->options['delimiter'][1].
- "\n$1 ". // indent it one more space than
before, so an 'else' goes with the 'if' :-)
- $this->options['delimiter'][0].
- "foreach($2 ",
-
+ "if(is_array(@$2) && sizeof(@$2)>0)foreach($2 ",
$input);
}