Source for file if.php
Documentation is available at if.php
* Conditional block, the syntax is very similar to the php one, allowing () || && and
* other php operators. Additional operators and their equivalent php syntax are as follow :
* X is [not] div by Y -> (X % Y) == 0
* X is [not] even [by Y] -> (X % 2) == 0 or ((X/Y) % 2) == 0
* X is [not] odd [by Y] -> (X % 2) != 0 or ((X/Y) % 2) != 0
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
* This file is released under the LGPL
* "GNU Lesser General Public License"
* More information can be found here:
* {@link http://www.gnu.org/copyleft/lesser.html}
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
public function init(array $rest)
public static function replaceKeywords(array $params, Dwoo_Compiler $compiler)
while (list
($k,$v) =
each($params)) {
switch(substr($v, 0, 1) ===
'"' ||
substr($v, 0, 1) ===
'\'' ?
substr($v, 1, -
1) :
$v) {
if (isset
($params[$k+
1]) &&
trim($params[$k+
1], '"\'') ===
'not') {
if (!isset
($params[$k+
$ptr])) {
$params[$k+
$ptr] =
trim($params[$k+
$ptr], '"\'');
switch($params[$k+
$ptr]) {
if (isset
($params[$k+
$ptr+
1]) &&
trim($params[$k+
$ptr+
1], '"\'') ===
'by') {
$p[] =
' % '.
$params[$k+
$ptr+
2].
' '.
($negate?
'!':
'=').
'== 0';
throw
new Dwoo_Compilation_Exception($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found '.
$params[$k-
1].
' is '.
($negate?
'not ':
'').
'div '.
$params[$k+
$ptr+
1].
' '.
$params[$k+
$ptr+
2]);
if (isset
($params[$k+
$ptr+
1]) &&
trim($params[$k+
$ptr+
1], '"\'') ===
'by') {
$p[] =
'('.
$a .
' / '.
$b.
') % 2 '.
($negate?
'!':
'=').
'== 0';
$p[] =
$a.
' % 2 '.
($negate?
'!':
'=').
'== 0';
if (isset
($params[$k+
$ptr+
1]) &&
trim($params[$k+
$ptr+
1], '"\'') ===
'by') {
$p[] =
'('.
$a .
' / '.
$b.
') % 2 '.
($negate?
'=':
'!').
'== 0';
$p[] =
$a.
' % 2 '.
($negate?
'=':
'!').
'== 0';
throw
new Dwoo_Compilation_Exception($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found '.
$params[$k-
1].
' is '.
$params[$k+
$ptr+
1]);
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
$currentBlock =
& $compiler->getCurrentBlock();
$params =
$compiler->getCompiledParams($params);
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
return $content .
$params['postOutput'];
Documentation generated on Sun, 03 Aug 2008 15:12:39 +0200 by phpDocumentor 1.4.0