Пример #1
0
function makeCase($nums)
{
    if (!is_array($nums)) {
        $nums = array($nums);
    }
    $list = array();
    return alt("{case " . implode(",", $nums) . "}\n    {\"{case " . var_export(implode(",", $nums), true) . "}\"}\n{/case}\n");
}
Пример #2
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/if/correct/if_else_elseif_nested.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$empty = alt('');
$if = perm("if(%cnt%)\n{if \$_true}", "\n    ok(%cnt%)\n", "{/if}/if(%cnt%)\n");
$if2 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{/if}ok(%cnt%)\n/if(%cnt%)\n");
$ifElse = perm("if(%cnt%)\n{if \$_true}", "\n    ok(%cnt%)\n", "{else}", "\n    fail(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElse2 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{else}", "\n    ok(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElseIf = perm("if(%cnt%)\n{if \$_true}", "\n    ok(%cnt%)\n", "{elseif \$_false}", "\n    fail(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElseIf2 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{elseif \$_true}", "\n    ok(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElseIf3 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{elseif \$_false}", "\n    fail(%cnt%)\n", "{/if}ok(%cnt%)\n/if(%cnt%)\n");
$ifElseIfElse = perm("if(%cnt%)\n{if \$_true}", "\n    ok(%cnt%)\n", "{elseif \$_false}", "\n    fail(%cnt%)\n", "{else}", "\n    fail(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElseIfElse2 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{elseif \$_true}", "\n    ok(%cnt%)\n", "{else}", "\n    fail(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifElseIfElse3 = perm("if(%cnt%)\n{if \$_false}", "\n    fail(%cnt%)\n", "{elseif \$_false}", "\n    fail(%cnt%)\n", "{else}", "\n    ok(%cnt%)\n", "{/if}/if(%cnt%)\n");
$ifNested = perm("if(%cnt%)\n{if \$_true}\n", altI('    ', clone $if, clone $ifElse, clone $ifElseIf, clone $ifElseIfElse, clone $ifElseIfElse2), "{/if}/if(%cnt%)\n");
$ifNested2 = perm("{if \$_true}\n", alt('===>', clone $if, clone $ifElse, clone $ifElseIf, clone $ifElseIfElse, clone $ifElseIfElse2, clone $ifNested), "{/if}");
$list = perm(alt(clone $if, clone $if2, clone $ifElse, clone $ifElse2, clone $ifElseIf, clone $ifElseIf2, clone $ifElseIf3, clone $ifElseIfElse, clone $ifElseIfElse2, clone $ifElseIfElse3, clone $ifNested));
$a = app("if/correct/if_else_elseif_nested.in", $argv);
$a->output("{var \$_false = false,\n     \$_true = true}\n");
$i = 0;
do {
    $str = $list->generate();
    $a->output(str_replace("%cnt%", $i, $str) . "\n");
    ++$i;
} while ($list->increase());
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/array_fetch/correct/comments.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$list = perm("{\$a[", clone $comments, '0', clone $comments, "]}\n");
$a = app("array_fetch/correct/comments.in", $argv);
$a->output("{var \$a = array( 0 => 'foo' )}\n");
$i = 0;
do {
    $str = $list->generate();
    $a->output($str);
    ++$i;
} while ($list->increase());
$a->close();
$a->store(str_repeat("foo\n", $i), $a->dir . "/array_fetch/correct/comments.out");
Пример #4
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/literals/array_create_with_comments2.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$list = perm('debug_dump( array', '(', alt(perm(clone $comments, alt('0'), clone $comments), perm(clone $comments, alt('0'), clone $comments, alt(','), clone $comments)), ') )');
$a = app("literals/array_create_with_comments2.in", $argv);
do {
    $str = $list->generate();
    $a->output("{" . $str . "}\n");
} while ($list->increase());
Пример #5
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/blocks/incorrect/non_matching_block_*.in
$blocksStart = alt("", "{foreach \$array as \$bar}", "{while \$_false}", "{delimiter}", "{if \$foo}", "{elseif \$foo}", "{else}", "{switch \$foo}", "{case 5}", "{default}");
$blocksEnd = alt("", "{/foreach}", "{/while}", "{/delimiter}", "{/if}", "{/switch}", "{/case}", "{/default}");
$blocksStart1 = clone $blocksStart;
$blocksEnd1 = clone $blocksEnd;
$blocksStartEnd = perm($blocksStart1, "\n    {\$foo}\n", $blocksEnd1, "\n");
$blocksStart2 = clone $blocksStart;
$blocksEnd2 = clone $blocksEnd;
$blocksStartEnd2 = perm($blocksStart2, "\n    {\$foo}\n", $blocksEnd2, "\n");
$blocksNested = alt(perm("{foreach \$array as \$bar}\n", altI('    ', $blocksStartEnd2), "{/foreach}\n"));
$alt = alt($blocksStartEnd, $blocksNested);
$list = perm($alt);
$dir = dirname(__FILE__) . "/../regression_tests/blocks/incorrect/";
$a = app("", $argv, $dir);
$i = 1;
$top = "{var \$foo = 1, \$_false = false, \$array = array( 1, 2 )}\n";
if (!$a->outputToFile) {
    echo $top;
}
$inCount = 0;
$outCount = 0;
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $inFile = $dir . "/non_matching_block_" . $num . ".in";
    $outFile = $dir . "/non_matching_block_" . $num . ".out";
    $useEntry = false;
    // Check for valid entries.
Пример #6
0
 /////////stuff//////////////////
 $genC .= 'mkdir "' . $thName . '"' . "\n";
 $dir_handle = @opendir("{$origTh}");
 while ($file = readdir($dir_handle)) {
     if (is_dir("{$origTh}/{$file}") && strlen(strstr($file, ".")) == 0) {
         //$genC.="mkdir '$thName/$file'\n";
         $genC .= 'mkdir "' . $thName . '/' . $file . '"' . "\n";
         echo "<b>{$origTh}/{$file}</b><br>";
         ////////////LA LA LA LA //////////////////
         $dir_handle2 = @opendir("{$origTh}/{$file}");
         while ($imgf = readdir($dir_handle2)) {
             if (is_dir("{$origTh}/{$imgf}") == false && strlen(strstr($imgf, ".")) != 0) {
                 if (strlen(strstr($imgf, ".gif")) != 0 || strlen(strstr($imgf, ".png")) != 0) {
                     echo "&nbsp;&nbsp;&nbsp;&nbsp;{$origTh}/{$file}/{$imgf}<br>";
                     ////////////WEEE WHITESPACE/////////////////
                     $genC .= alt("{$file}/{$imgf}", $origTh);
                 }
                 //////1 closed parenthesis
             }
             //////2closed parenthesis
         }
         //////3closed parenthesis
     }
     //////4closed parenthesis
 }
 //////5 closed parenthesis!!!!!!!!!!!!!!!!!!!!!!!
 closedir($dir_handle);
 ////OH NOO; bye bye dir_handle
 //////MWORE WHYTESPCE
 if (strlen(file_get_contents("xtheme-{$thName}.css")) < 100) {
     copy("../css/xtheme-{$thName}.css", "xtheme-{$thName}.css");
Пример #7
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/array_fetch/correct/indexes.in
$ws = alt("", " ", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$indexPre = perm("[1]", clone $comments, "[]", clone $comments);
$indexPost = perm("[2]");
$entry1 = alt("", perm(clone $comments, "[1]"), perm("[1]", clone $comments, "[2]"), perm($indexPre, $indexPost));
$var = perm("{\$a[0]");
$fetch = perm($var, $entry1, "}");
$list = perm($fetch, "\n");
$a = app("array_fetch/correct/indexes.in", $argv);
$top = "{var \$a = array( 0 => array( 1 => array( 2 => 'foo' ) ) )}\n";
$a->output($top);
$i = 1;
$out = '';
$map = array(0 => "Array\n", 1 => "Array\n", 2 => "foo\n", 3 => '');
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    if ($entry1->index == 3) {
        $a->store("{* file: indexes_{$num}.in *}\n" . $top . $str, $a->dir . "/array_fetch/incorrect/indexes_{$num}.in");
        /*        $text = $fetch->generate();
                $len = strlen( $text );
                $a->store( "mock:3:{$len}: Unexpected array append '[]'. Did you forget an expresssion between the brackets?\n" .
                           "\n" .
                           "{$text}\n" .
                           str_repeat( " ", ezcTemplatePermutation::column( $var->generate() . $indexPre->generate() ) ) . "^\n",
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/blocks/incorrect/block_invalid_closing_*.in
$singleBlockNames = alt("var", "cycle", "use", "increment", "decrement", "reset", "return", "break", "skip", "continue", "else", "elseif", "include", "ldelim", "rdelim");
$nestedBlockNames = alt("foreach", "while", "if", "switch", "case", "default", "delimiter", "literal");
$otherNames = alt("tru", "fals", "ray");
$alts = alt($singleBlockNames, $nestedBlockNames, $otherNames);
$data = alt("", " \$foo");
$lineStart = perm("{/", $alts);
$line = perm($lineStart, $data, "}");
$list = perm($line, "\n");
$a = app("", $argv);
$dir = $a->dir;
$i = 1;
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $fileIn = $dir . "/blocks/incorrect/block_invalid_closing_" . $num . ".in";
    $fileOut = $dir . "/blocks/incorrect/block_invalid_closing_" . $num . ".out";
    $name = $alts->generate();
    $a->store("{* file: " . "block_invalid_closing_" . $num . ".in" . " *}\n{var \$foo = \"T42p\"}\n" . $str . "\n", $fileIn);
    if ($alts->index == 0) {
        $dataText = $data->generate();
        $a->store("mock:3:2: This block cannot be closed.\n" . "\n" . "{/{$name}{$dataText}}\n" . " ^\n", $fileOut);
    } elseif ($alts->index == 1) {
        $lineText = $line->generate();
        if ($data->index == 0) {
            $offset = strlen($line->generate()) + 1;
            $a->store("mock:3:{$offset}: Found closing block {/{$name}} without an opening block.\n" . "\n" . "{$lineText}\n" . str_repeat(" ", $offset - 1) . "^\n", $fileOut);
        } else {
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/expressions/correct/modifying_array_operators_*.in
$modifyingOperators = alt("=", "+=", "-=", "*=", "/=", "%=", ".=");
$constValues = alt("5", "-\$foo");
$modify = perm("\$arr['foo']", " ", $modifyingOperators, alt(perm(alt("", perm(" \$arr2['foo']['bar'] ", clone $modifyingOperators)), " ", 5)));
$modifiers = alt($modify);
$main = alt(perm("[{\$arr = \$arr_}{\$arr2 = \$arr2_}{", $modifiers, "}", "{str_number( \$arr['foo'], 5, ',', '' )},{str_number( \$arr2['foo']['bar'], 5, ',', '' )}]\n"));
$list = perm("%num%:", $main);
// special tests
// $a == $b == $c (should produce proper PHP code ) => ($a == $b) == $c
// $a = $b = $c (should produce proper PHP code) $a = ($b = $c)
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/modifying_array_operators.in", $argv);
$objCode = "if ( !class_exists( 'ezcTemplateTestModOpMyClass', false ) )\n" . "{\n" . "  class ezcTemplateTestModOpMyClass\n" . "  {\n" . "    public \$foo = 301;\n" . "  }\n" . "}\n" . "\$obj = new ezcTemplateTestModOpMyClass();\n";
$i = 1;
$top = "{var \$foo = 42, \$arr_ = array( 'foo' => 401 ), \$arr2_ = array( 'foo' => array( 'bar' => 501 ) )}\n{var \$arr, \$arr2}\n";
$topPHP = "\$foo = 42; \$arr_ = array( 'foo' => 401 ); \$arr2_ = array( 'foo' => array( 'bar' => 501 ) );\n";
$phpCode = '';
$fileOut = $dir . "expressions/correct/modifying_array_operators.out";
$filePHP = $dir . "expressions/correct/modifying_array_operators.php";
$a->output($top);
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $str = str_replace("%num%", $num, $str);
    $fileIn = $dir . "expressions/correct/modifying_array_operators_" . $num . ".in";
    $a->output($str);
    if ($main->index == 0) {
        $phpCode .= "\$arr = \$arr_; \$arr2 = \$arr2_;\n" . $modifiers->generate() . ";\n" . "echo '{$num}:[', number_format( \$arr['foo'], 5, ',', '' ), ',', number_format( \$arr2['foo']['bar'], 5, ',', '' ), \"]\\n\";\n";
Пример #10
0
	/**
	 * form elements for deleting
	 *
	 * @param object  $object
	 */
	protected function display_list_delete($object) {

		if ($this->reference_check($object)) return;

		if ($this->enable_delete_single) {
?>
			<img src="img/delete.png" width="21" height="16" class="iconbutton" <?alt(_("delete"))?> onclick="return submit_delete_button(<?php 
echo $object->id;
?>
);">
<?
		}
		if ($this->enable_delete_checked) {
?>
			<input type="checkbox" name="delete[]" value="<?php 
echo $object->id;
?>
">
<?
		}

	}
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/expressions/correct/modifying_property_operators_*.in
$modifyingOperators = alt("=", "+=", "-=", "*=", "/=", "%=", ".=");
$constValues = alt("5", "-\$foo");
$modify = perm("\$obj->prop1", " ", $modifyingOperators, alt(perm(alt("", perm(" \$obj->subprop->prop2 ", clone $modifyingOperators)), " ", 5)));
$modifiers = alt($modify);
$main = alt(perm("[{\$obj->prop1 = \$objval1}{\$obj->subprop->prop2 = \$objval2}{", $modifiers, "}", "{str_number( \$obj->prop1, 5, ',', '' )},{str_number( \$obj->subprop->prop2, 5, ',', '' )}]\n"));
$list = perm("%num%:", $main);
// special tests
// $a == $b == $c (should produce proper PHP code ) => ($a == $b) == $c
// $a = $b = $c (should produce proper PHP code) $a = ($b = $c)
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/modifying_property_operators.in", $argv);
$objCode = "if ( !class_exists( 'ezcTemplateTestModObjOpMySubClass', false ) )\n" . "{\n" . "  class ezcTemplateTestModObjOpMySubClass\n" . "  {\n" . "    public \$prop2 = 501;\n" . "  }\n" . "}\n" . "if ( !class_exists( 'ezcTemplateTestModObjOpMyClass', false ) )\n" . "{\n" . "  class ezcTemplateTestModObjOpMyClass\n" . "  {\n" . "    public \$prop1 = 401;\n" . "    public \$subprop;\n" . "    public function __construct()\n" . "    {\n" . "      \$this->subprop = new ezcTemplateTestModObjOpMySubClass();\n" . "    }\n" . "  }\n" . "}\n" . "\$obj = new ezcTemplateTestModObjOpMyClass();\n";
$objCodeSend = $objCode . "\$v = new ezcTemplateVariableCollection();\n" . "\$v->obj = \$obj;\n" . "return \$v;\n";
$i = 1;
$top = "{use \$obj}\n{var \$foo = 42, \$objval1 = 401, \$objval2 = 501}\n";
$topPHP = "\$foo = 42; \$objval1 = 401; \$objval2 = 501;\n";
$phpCode = '';
$fileOut = $dir . "expressions/correct/modifying_property_operators.out";
$filePHP = $dir . "expressions/correct/modifying_property_operators.php";
$fileSend = $dir . "expressions/correct/modifying_property_operators.send";
$a->output($top);
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $str = str_replace("%num%", $num, $str);
    $fileIn = $dir . "expressions/correct/modifying_property_operators_" . $num . ".in";
    $a->output($str);
Пример #12
0
                        "\n"
                        );

$blocksNested = alt( perm( "{foreach \$array as \$bar}\n",
                           altI( '    ', clone $blocksStartEnd ),
                           "{/foreach}\n"
                           ) );*/
$preList = perm(clone $blockNames, clone $preText);
$postList = perm(clone $preText, clone $blockNames);
$prePostList = perm(clone $preText, clone $blockNames, clone $preText);
/*
mock:2:2: Unknown block <var_>.

{var_}
 ^
*/
$alternatives = alt($preList, $postList, $prePostList);
$list = perm("{", $alternatives, "}\n");
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("", $argv);
$i = 1;
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $fileIn = $dir . "blocks/incorrect/block_mangled_pre_post_" . $num . ".in";
    $fileOut = $dir . "blocks/incorrect/block_mangled_pre_post_" . $num . ".out";
    $name = $alternatives->generate();
    $a->store("{* file: " . "non_matching_block_" . $num . ".in" . " *}\n" . $str . "\n", $fileIn);
    $a->store("mock:2:2: Unknown block <{$name}>.\n" . "\n" . "{{$name}}\n" . " ^\n", $fileOut);
    ++$i;
} while ($list->increase());
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/expressions/correct/whitespace_usage_*.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$binOperators = alt("+", "-", "*", "%", "==", "===", "!=", "!==", "<", "<=", ">", ">=", "&&", "||", ".");
$binOperatorsSlash = alt("/");
$bins = perm("5", alt(perm(clone $comments, $binOperators, clone $comments), perm(clone $comments, $binOperatorsSlash, " ", $comments)), "5");
$main = perm("[{", $bins, "}]\n");
$list = perm("%num%:", $main);
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/whitespace_usage_0001.in", $argv);
$i = 1;
$top = "";
$topPHP = "";
$phpCode = array(1 => '');
$sendMap = array(1 => false);
// Invalid cases in PHP:
// 5//*asdf*/5
// 5. 5
// 5 .5
$block = 1;
$a->output($top);
do {
    if ($i > 1 && ($i - 1) % 50 == 0) {
        $a->close();
        ++$block;
        $num2 = sprintf("%04d", $block);
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/if/incorrect/modifying_expression_*.in
$binOperators = alt("+", "-", "*", "/", "%", "==", "===", "!=", "!==", "<", "<=", ">", ">=", "&&", "||", ".");
$modifyingOperators = alt("=", "+=", "-=", "*=", "/=", "%=", ".=");
$mod = perm("\$foo ", $modifyingOperators, " 5");
$binRhs = alt(perm(" ( \$bar ", $modifyingOperators, " 5 )"), perm(" \$bar++"), perm(" \$bar--"), perm(" ++\$bar"), perm(" --\$bar"));
$bin = perm("\$foo ", "+ ", alt(clone $binRhs, perm("( ", clone $binRhs, " )")));
$ops = alt($mod, $bin);
$main = alt($ops, perm("( ", $ops, " )"));
$list = perm("%num%:", "{if ", $main, "}", "this should never appear", "{/if}\n");
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("", $argv);
$i = 1;
$top = "{var \$foo = 42, \$bar = 101}\n";
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $str = str_replace("%num%", $num, $str);
    $fileIn = $dir . "if/incorrect/modifying_expression_" . $num . ".in";
    $a->store("{* file: " . "if/incorrect/modifying_expression_" . $num . ".in" . " *}\n" . $top . $str, $fileIn);
    ++$i;
} while ($list->increase());
Пример #15
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/foreach/correct/nested_with_delimiter_*.in
$blockStart = altMaster(altSlave("{\$i = 0}\n{foreach \$foo as \$bar}\n", "{\$num = 0}{\$i = 0}\n{while \$num<3}\n{\$bar = \$num}\n{\$num++}\n", "{\$i = 0}\n{if \$foo[1]}\n"), altSlave("{++\$i}\n{/foreach}\n", "{++\$i}\n{/while}\n", "{/if}\n"));
$blockEnd = $blockStart->slaves[1];
$innerBlocks1 = alt("{delimiter}\n" . "    {\$i}:~~~~delim~~~~\n" . "{/delimiter}\n", "{if \$bar}\n" . "    {\$i}:[if]\$bar is true[/if]\n" . "{else}\n" . "    {\$i}:[if]\$bar is false[/if]\n" . "{/if}\n", "{switch \$bar}\n" . "{case 1}\n" . "    {\$i}:[switch]1[/switch]\n" . "{/case}\n" . "{case 2}\n" . "    {\$i}:[switch]2[/switch]\n" . "{/case}\n" . "{default}\n" . "    {\$i}:[switch]default({\$bar})[/switch]\n" . "{/default}\n" . "{/switch}\n");
$delimBlocks = alt("{delimiter}\n" . "    {\$i}:====delim====\n" . "{/delimiter}\n" . "{delimiter modulo 2}\n" . "    {\$i}:____delim____\n" . "{/delimiter}\n");
$blockStart2 = clone $blockStart;
$blockEnd2 = $blockStart2->slaves[1];
$innerBlocks2 = clone $innerBlocks1;
/*$innerBlocks2->replace( "\$foo", "\$foo2" );
$innerBlocks2->replace( "\$bar", "\$bar2" );
$innerBlocks2->replace( "\$num", "\$num2" );
$innerBlocks2->replace( "{\$i}", "{\$i}:{\$j}" );
$innerBlocks2->replace( "{\$i = 0}", "{\$j = 0}" );
$innerBlocks2->replace( "~~~~delim~~~~", "~~delim~~" );*/
$outerBlocks2 = perm($blockStart2, indent(perm($innerBlocks2, $delimBlocks), "    "), $blockEnd2);
$outerBlocks2->replace("\$foo", "\$foo2");
$outerBlocks2->replace("\$bar", "\$bar2");
$outerBlocks2->replace("\$num", "\$num2");
$outerBlocks2->replace("{\$i}", "{\$i}:{\$j}");
$outerBlocks2->replace("{\$i = 0}", "{\$j = 0}");
$outerBlocks2->replace("{++\$i}", "{++\$j}");
$outerBlocks2->replace("~~~~delim~~~~", "~~delim~~");
$outerBlocks = perm("\\{%num%\n", "{foreach 1..1 as \$blackhole}\n", indent(perm($blockStart, indent(perm($innerBlocks1, $outerBlocks2), "    "), $blockEnd), "    "), "{/foreach}\n", "\\}\n");
$list = perm($outerBlocks);
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("", $argv);
$i = 1;
$top = "{var \$foo = array( 0, 1, 3 ), \$foo2 = array( '', 'foo' ), \$bar = 0, \$bar2 = 0, \$num = 0, \$num2 = 0, \$i = 0, \$j = 0}\n";
Пример #16
0
/**
 * Output a page for this framework.
 *
 */
function about()
{
    echo "<!DOCTYPE html>\n";
    echo "<html>\n";
    echo "<head>\n";
    echo "<meta charset=\"" . t(MAIN_CHARSET, true) . "\" />\n";
    echo "<title>levis: PHP Framework</title>\n";
    style();
    echo "</head>\n";
    echo "<body>\n";
    echo "<h1>levis: PHP Framework</h1>\n";
    echo "<p>Version " . VERSION_NUMBER . ' (' . VERSION_UPDATE . ")</p>\n";
    echo "<h2>Menu</h2>\n";
    echo "<ul>\n";
    echo "<li><a href=\"" . t(MAIN_FILE, true) . "/?_mode=info_php\">phpinfo</a></li>\n";
    if (DATABASE_TYPE) {
        echo "<li><a href=\"" . t(MAIN_FILE, true) . "/?_mode=db_admin\">database</a></li>\n";
    }
    if (file_exists(DATABASE_MIGRATE_PATH)) {
        echo "<li><a href=\"" . t(MAIN_FILE, true) . "/?_mode=db_migrate\">migrate</a></li>\n";
    }
    if (file_exists(DATABASE_SCAFFOLD_PATH)) {
        echo "<li><a href=\"" . t(MAIN_FILE, true) . "/?_mode=db_scaffold\">scaffold</a></li>\n";
    }
    if (file_exists(TEST_PATH)) {
        echo "<li><a href=\"" . t(MAIN_FILE, true) . "/?_mode=test_index\">test</a></li>\n";
    }
    echo "</ul>\n";
    echo "<h2>Configuration</h2>\n";
    echo "<h3>Main</h3>\n";
    echo "<dl>\n";
    echo "<dt>main file</dt>\n";
    echo "<dd><code>" . alt(MAIN_FILE, '-') . "</code></dd>\n";
    echo "<dt>path to libraries</dt>\n";
    echo "<dd><code>" . alt(MAIN_LIBRARY_PATH, '-') . "</code></dd>\n";
    echo "<dt>path to application</dt>\n";
    echo "<dd><code>" . alt(MAIN_APPLICATION_PATH, '-') . "</code></dd>\n";
    echo "<dt>default mode</dt>\n";
    echo "<dd><code>" . alt(MAIN_DEFAULT_MODE, '-') . "</code></dd>\n";
    echo "<dt>default work</dt>\n";
    echo "<dd><code>" . alt(MAIN_DEFAULT_WORK, '-') . "</code></dd>\n";
    echo "<dt>internal encoding</dt>\n";
    echo "<dd><code>" . alt(MAIN_INTERNAL_ENCODING, '-') . "</code></dd>\n";
    echo "<dt>charset</dt>\n";
    echo "<dd><code>" . alt(MAIN_CHARSET, '-') . "</code></dd>\n";
    echo "<dt>time</dt>\n";
    echo "<dd><code>" . MAIN_TIME . "</code></dd>\n";
    echo "</dl>\n";
    echo "<dl>\n";
    echo "<dt>path to models</dt>\n";
    echo "<dd><code>" . MAIN_APPLICATION_PATH . 'app/models/' . "</code></dd>\n";
    echo "<dt>path to views</dt>\n";
    echo "<dd><code>" . MAIN_APPLICATION_PATH . 'app/views/' . "</code></dd>\n";
    echo "<dt>path to controllers</dt>\n";
    echo "<dd><code>" . MAIN_APPLICATION_PATH . 'app/controllers/' . "</code></dd>\n";
    echo "<dt>path to core libraries</dt>\n";
    echo "<dd><code>" . MAIN_LIBRARY_PATH . 'libs/cores/' . "</code></dd>\n";
    echo "<dt>path to plugins</dt>\n";
    echo "<dd><code>" . MAIN_LIBRARY_PATH . 'libs/plugins/' . "</code></dd>\n";
    echo "</dl>\n";
    if (DATABASE_TYPE) {
        echo "<h3>Database</h3>\n";
        echo "<dl>\n";
        echo "<dt>type</dt>\n";
        echo "<dd><code>" . DATABASE_TYPE . "</code></dd>\n";
        echo "<dt>name</dt>\n";
        echo "<dd><code>" . alt(DATABASE_NAME, '-') . "</code></dd>\n";
        echo "<dt>prefix</dt>\n";
        echo "<dd><code>" . alt(DATABASE_PREFIX, '-') . "</code></dd>\n";
        echo "<dt>charset</dt>\n";
        echo "<dd><code>" . alt(DATABASE_CHARSET, '-') . "</code></dd>\n";
        echo "<dt>charset input from</dt>\n";
        echo "<dd><code>" . alt(DATABASE_CHARSET_INPUT_FROM, '-') . "</code></dd>\n";
        echo "<dt>charset input to</dt>\n";
        echo "<dd><code>" . alt(DATABASE_CHARSET_INPUT_TO, '-') . "</code></dd>\n";
        echo "<dt>charset output from</dt>\n";
        echo "<dd><code>" . alt(DATABASE_CHARSET_OUTPUT_FROM, '-') . "</code></dd>\n";
        echo "<dt>charset output to</dt>\n";
        echo "<dd><code>" . alt(DATABASE_CHARSET_OUTPUT_TO, '-') . "</code></dd>\n";
        echo "<dt>migrate path</dt>\n";
        echo "<dd><code>" . alt(DATABASE_MIGRATE_PATH, '-') . "</code></dd>\n";
        echo "<dt>scaffold path</dt>\n";
        echo "<dd><code>" . alt(DATABASE_SCAFFOLD_PATH, '-') . "</code></dd>\n";
        echo "<dt>backup path</dt>\n";
        echo "<dd><code>" . alt(DATABASE_BACKUP_PATH, '-') . "</code></dd>\n";
        echo "</dl>\n";
    }
    echo "<h3>Session</h3>\n";
    echo "<dl>\n";
    echo "<dt>autostart</dt>\n";
    echo "<dd><code>" . (SESSION_AUTOSTART ? 'true' : 'false') . "</code></dd>\n";
    echo "<dt>lifetime</dt>\n";
    echo "<dd><code>" . SESSION_LIFETIME . "</code></dd>\n";
    echo "<dt>path</dt>\n";
    echo "<dd><code>" . alt(SESSION_PATH, '-') . "</code></dd>\n";
    echo "<dt>cache</dt>\n";
    echo "<dd><code>" . alt(SESSION_CACHE, '-') . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Token</h3>\n";
    echo "<dl>\n";
    echo "<dt>span</dt>\n";
    echo "<dd><code>" . TOKEN_SPAN . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Regexp</h3>\n";
    echo "<dl>\n";
    echo "<dt>type</dt>\n";
    echo "<dd><code>" . alt(REGEXP_TYPE, '-') . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Page</h3>\n";
    echo "<dl>\n";
    echo "<dt>path</dt>\n";
    echo "<dd><code>" . alt(PAGE_PATH, '-') . "</code></dd>\n";
    echo "<dt>controller</dt>\n";
    echo "<dd><code>" . alt(PAGE_CONTROLLER, '-') . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Test</h3>\n";
    echo "<dl>\n";
    echo "<dt>path</dt>\n";
    echo "<dd><code>" . alt(TEST_PATH, '-') . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Debug</h3>\n";
    echo "<dl>\n";
    echo "<dt>level</dt>\n";
    echo "<dd><code>" . DEBUG_LEVEL . "</code></dd>\n";
    echo "<dt>password</dt>\n";
    echo "<dd><code>" . alt(str_repeat('*', strlen(DEBUG_PASSWORD)), '-') . "</code></dd>\n";
    echo "<dt>addr</dt>\n";
    echo "<dd><code>" . alt(DEBUG_ADDR, '-') . "</code></dd>\n";
    echo "</dl>\n";
    echo "<h3>Logging</h3>\n";
    echo "<dl>\n";
    echo "<dt>path</dt>\n";
    echo "<dd><code>" . alt(LOGGING_PATH, '-') . "</code></dd>\n";
    echo "<dt>message</dt>\n";
    echo "<dd><code>" . (LOGGING_MESSAGE ? 'true' : 'false') . "</code></dd>\n";
    echo "<dt>get</dt>\n";
    echo "<dd><code>" . (LOGGING_GET ? 'true' : 'false') . "</code></dd>\n";
    echo "<dt>post</dt>\n";
    echo "<dd><code>" . (LOGGING_POST ? 'true' : 'false') . "</code></dd>\n";
    echo "<dt>files</dt>\n";
    echo "<dd><code>" . (LOGGING_FILES ? 'true' : 'false') . "</code></dd>\n";
    echo "</dl>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit;
}
Пример #17
0
	/**
	 * content area of one comment
	 *
	 * @param Comment $comment
	 */
	private function display_comment_content(Comment $comment) {
?>
		<p><?php 
echo content2html($comment->content);
?>
</p>
<?

		// reply
		if (
			self::$proposal->allowed_add_comments($this->rubric) and
			self::$parent!=$comment->id and
			!$comment->removed
		) {
			if (Login::access_allowed("comment")) {
				$open = self::$open;
				$open[] = $comment->id;
				$open = array_unique($open);
?>
		<div class="reply"><a href="<?php 
echo URI::append(['open' => $open, 'parent' => $comment->id]);
?>
#form" class="iconlink"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></a></div>
<?
			} else {
?>
		<div class="reply iconlink disabled"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></div>
<?
			}
		}

		// rating and remove/restore
		if ($comment->rating) {
			?><span class="rating" title="<?php 
echo _("sum of ratings");
?>
">+<?php 
echo $comment->rating;
?>
</span> <?
		}
		if (Login::$admin) {
			form(URI::same(), 'class="button"');
?>
<input type="hidden" name="id" value="<?php 
echo $comment->id;
?>
">
<?
			if ($comment->removed) {
?>
<input type="hidden" name="action" value="restore_comment">
<input type="submit" value="<?php 
echo _("restore");
?>
">
<?
			} else {
?>
<input type="hidden" name="action" value="remove_comment">
<input type="submit" value="<?php 
echo _("remove");
?>
">
<?
			}
			form_end();
		} elseif (
			self::$proposal->allowed_add_comments($this->rubric) and
			// don't allow to rate ones own comments
			!$comment->is_author() and
			// don't allow to rate removed comments
			!$comment->removed
		) {
			if (Login::access_allowed("rate")) {
				$disabled = "";
				$uri = URI::same()."#comment".$comment->id;
			} else {
				$disabled = " disabled";
				$uri = "";
			}
			if ($comment->score) {
				form($uri, 'class="button rating reset"');
?>
<input type="hidden" name="comment" value="<?php 
echo $comment->id;
?>
">
<input type="hidden" name="action" value="reset_rating">
<input type="submit" value="0"<?php 
echo $disabled;
?>
>
<?
				form_end();
			}
			for ($score=1; $score <= Comment::rating_score_max; $score++) {
				form($uri, 'class="button rating'.($score <= $comment->score?' selected':'').'"');
?>
<input type="hidden" name="comment" value="<?php 
echo $comment->id;
?>
">
<input type="hidden" name="action" value="set_rating">
<input type="hidden" name="rating" value="<?php 
echo $score;
?>
">
<input type="submit" value="+<?php 
echo $score;
?>
"<?php 
echo $disabled;
?>
>
<?
				form_end();
			}
		}

	}
Пример #18
0
	/**
	 * display table part for all proposals of the issue
	 *
	 * @param array   $proposals         array of objects
	 * @param boolean $submitted
	 * @param integer $period_rowspan
	 * @param boolean $show_results      (optional) display the result column
	 * @param integer $selected_proposal (optional)
	 * @param array   $vote              (optional)
	 * @param boolean $show_ngroup       (optional)
	 */
	function display_proposals(array $proposals, $submitted, $period_rowspan, $show_results=false, $selected_proposal=0, array $vote=array(), $show_ngroup=false) {

		$first = true;
		$first_admitted = true;
		$num_rows = count($proposals);
		foreach ( $proposals as $proposal ) {
			/** @var $proposal Proposal */

			$link = "proposal.php?id=".$proposal->id;

?>
	<tr class="proposal"<?
			if ($first) { ?> id="issue<?=$this->id?>"<? }
			?>>
<?
			if ($show_ngroup and $first) {
?>
		<td rowspan="<?=$num_rows?>" scope="row"><?=$proposal->issue()->area()->ngroup()->name?></td>
<?
			}
?>
		<td class="proposal_link<?
			if ($selected_proposal==$proposal->id) { ?>_active<? }
			$tooltip = "";
			switch ($proposal->state) {
			case "revoked":
				?> revoked<?
				$tooltip = ' title="'._("revoked proposal").'"';
				break;
			case "cancelled_interval":
			case "cancelled_debate":
			case "cancelled_admin":
				?> cancelled<?
				$tooltip = ' title="'._("cancelled proposal").'"';
				break;
			}
			?>" onClick="location.href='<?=$link?>'"><?
			if ($proposal->activity >= ACTIVITY_THRESHOLD) {
				?><img src="img/activity.png" width="31" height="16" class="activity" style="opacity:<?=min($proposal->activity / ACTIVITY_DIVISOR, 1)?>" <?alt(_("Recent activity"))?>><?
			}
			echo _("Proposal")?> <?=$proposal->id?>: <a href="<?=$link?>"<?=$tooltip?>><?=h($proposal->title)?></a></td>
<?
			if (BN=="vote.php") {
				$this->display_column_vote($proposal, $vote, $num_rows);
			} else {
				// column "support"
				if (BN!="admin_vote_result.php") {
?>
		<td class="support" onClick="location.href='<?=$link?>#supporters'"><?
					$proposal->bargraph_quorum($proposal->supported_by_member, $proposal->supporter_valid());
					?></td>
<?
				}
				// column "voting results"
				if ($show_results) {
					if (BN=="admin_vote_result.php") $this->display_column_admin_vote_result($proposal, $num_rows);
					$this->display_results($proposal, $proposals, $first);
				}
				// column "state"
				$this->display_column_state($proposal, $proposals, $first, $first_admitted, $num_rows);
				// columns "period" and "votingmode"
				if ($first) {
					$this->display_period($period_rowspan, $num_rows);
					$this->display_votingmode($num_rows, $submitted, $selected_proposal, $link);
				}
			}
?>
	</tr>
<?

			$first = false;
		}

	}
Пример #19
0
/**
 * display annotation by admins
 *
 * @param Proposal $proposal
 */
function display_annotation(Proposal $proposal) {
	if (Login::$admin) {
?>
<section id="annotation">
<?
		if (!empty($_GET['edit_annotation'])) {
?>
<h2><?=_("Annotation by admins")?></h2>
<?
			form(URI::same()."#annotation", "", "annotation", "annotation", true);
?>
<textarea name="annotation" cols="100" rows="3"><?=h($proposal->annotation)?></textarea>
<input type="hidden" name="action" value="save_annotation">
<input type="submit" value="<?=_("save")?>">
<?
			form_end();
		} else {
?>
<div class="add"><a href="<?=URI::append(['edit_annotation'=>1])?>#annotation" class="iconlink"><img src="img/edit.png" width="16" height="16" <?alt(_("edit"))?>></a></div>
<h2><?=_("Annotation by admins")?></h2>
<?=content2html($proposal->annotation)?>
<?
		}
?>
</section>
<?
	} elseif ($proposal->annotation) {
?>
<section id="annotation">
<h2><?=_("Annotation by admins")?></h2>
<?=content2html($proposal->annotation)?>
</section>
<?
	}
}
	/**
	 * table body
	 *
	 * overload method for line highlighting
	 *
	 * @param resource $result
	 * @param boolean $direct_edit
	 * @param boolean $show_edit_column
	 * @param integer $linescount
	 */
	protected function display_list_tbody($result, $direct_edit, $show_edit_column, $linescount) {
?>
<tbody>
<?

		if ($this->enable_pager) {

			if (!isset($_GET['page']) and isset($_GET['hl'])) {
				// go to the page with the record to be highlighted
				$line = 0;
				while ( $object = DB::fetch_object($result, $this->classname) ) {
					if ($_GET['hl']==$object->id) {
						$this->pager->page = $this->pager->page_for_line($line);
						break;
					}
					$line++;
				}
			}

			$this->pager->seek($result);
			$line = $this->pager->firstline;
		} else {
			$line = 0;
		}
		while ( $object = DB::fetch_object($result, $this->classname) and (!$this->enable_pager or $line <= $this->pager->lastline) ) {
?>
	<tr class="<?=stripes($line);
			if (isset($_GET['hl']) and $_GET['hl']==$object->id) { ?> highlight<? }
			?>">
<?

			// use the submitted values instead of the the record from the database
			if ($direct_edit and isset($this->directedit_objects[$object->id])) {
				$object = $this->directedit_objects[$object->id];
			}

			foreach ( $this->columns as $column ) {
				if (isset($column[3]) and $column[3]===false) continue;
?>
		<td<? $this->cellclass($column) ?>><?

				$method = "print_".(!empty($column[3])?$column[3]:"text");
				if (method_exists($this, $method)) {
					$this->$method(
						// parameters for print methods:
						($column[0]?$object->$column[0]:null), // 1 content
						$object,                               // 2 object
						$column,                               // 3 column description (array)
						$line,                                 // 4 line number (starting at 0)
						$linescount                            // 5 count of lines selected in the database
					);
				} else {
					$method = "dbtableadmin_".$method;
					$object->$method(
						// parameters for print methods:
						($column[0]?$object->$column[0]:null), // 1 content
						$column,                               // 2 column description (array)
						$line,                                 // 3 line number (starting at 0)
						$linescount                            // 4 count of lines selected in the database
					);
				}
				?></td>
<?
			}

			// right column for edit, delete, duplicate
			if ($show_edit_column) {
?>
		<td class="nowrap">
<?
				// edit
				if ($this->enable_edit) {
?>
			<a href="<?=URI::append(['id'=>$object->id])?>" class="iconlink"><img src="img/edit.png" width="16" height="16" <?alt(_("edit"))?>></a>
<?
				}
				// duplicate
				if ($this->enable_duplicate) {
?>
			<input type="button" value="<?=_("duplicate")?>" onclick="submit_button('duplicate', <?=$object->id?>);">
<?
				}
				// delete
				if ( $this->enable_delete_single or $this->enable_delete_checked ) {
					$this->display_list_delete($object);
				}
?>
		</td>
<?
			}

?>
	</tr>
<?
			$line++;
		} // end while

?>
</tbody>
<?
	}
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/literals/string_dq_escaped_characters.in
$chars = array();
$escChars = array();
for ($i = 1; $i < 256; ++$i) {
    $chars[] = chr($i);
    $escChars[] = "\\" . chr($i);
}
$allChars = array_merge($chars, $escChars);
$single = new ezcTemplatePermutationAlternative($chars);
$escaped = perm("\\", new ezcTemplatePermutationAlternative($chars));
$alt = alt($single, $escaped);
$list = perm($alt);
$a = app("literals/string_dq_escaped_characters.in", $argv);
$outFile = "literals/string_dq_escaped_characters.out";
$i = 0;
$out = '';
$a->output("{\"");
do {
    if ($i > 0 && $i % 8 == 0) {
        $a->output("\"}\n{\"");
        $out .= "\n";
    }
    if (isset($allChars[$i])) {
        $out .= $allChars[$i];
    }
    $str = $list->generate();
    if ($alt->index == 0 && $single->generate() == "\n") {
        $str = "\\n";
Пример #22
0
echo $G['sitename'];
?>
</a>&gt;<?php 
echo '<a href="' . $aClas[$aArc['cid']]['url'] . '">' . $aClas[$aArc['cid']]['name'] . '</a>';
?>
</p>

<div id="d"<?php 
echo empty($aArc['file']) ? '' : ' d="1"';
?>
><i><?php 
echo date('Y-m-d H:i', $aArc['ctime']);
?>
 浏览次数:-</i>
<?php 
echo alt($aArc['txt'], $aArc['title']);
?>
<br /><br />上一篇:<?php 
echo empty($aUp) ? '没有了...' : '<a href="/' . $aUp['id'] . '" n="1">' . $aUp['title'] . '</a>';
?>
<br />下一篇:<?php 
echo empty($aDo) ? '没有了...' : '<a href="/' . $aDo['id'] . '" n="1">' . $aDo['title'] . '</a>';
?>
</div>


<?php 
if (!empty($aNew)) {
    echo '<b id="bt"><a href="' . $aClas[$aArc['cid']]['url'] . '">' . $aClas[$aArc['cid']]['name'] . '</a></b><ul id="l">';
    foreach ($aNew as $a) {
        echo '<li><a href="/' . $a['id'] . '">' . $a['title'] . '</a></li>';
Пример #23
0
// Writes to: regression_tests/expressions/correct/binary_operators_*.in
$binOperators = alt("+", "-", "*", "/", "%", "==", "===", "!=", "!==", "<", "<=", ">", ">=", "&&", "||", ".");
$objectOperators = alt("->");
//"["
$modifyingOperators = alt("=", "+=", "-=", "*=", "/=", "%=", ".=");
$constValues = alt("5", "-\$foo");
$bin = perm(clone $constValues, " ", clone $binOperators, " ", clone $constValues);
$modify = perm("\$bar", " ", $modifyingOperators, alt("", perm(" \$bar2 ", clone $modifyingOperators)), " ", 5);
$object = perm("\$obj", " ", $objectOperators, " ", "foo");
$array = perm("\$arr['foo']");
$bin2 = perm("\$foo", " ", clone $binOperators, " ", 5);
$instanceOf = perm("\$foo", " ", "instanceof", " ", "'bar'");
$binCombination = perm(alt("( ", "!( "), alt(clone $bin2, $object, $array), " ) ", clone $binOperators, " ", clone $constValues);
$bins = alt($bin, $binCombination);
$modifiers = alt($modify);
$main = alt(perm("[{debug_dump( ", $bins, " )}]\n"), perm("[{\$bar = 101}{\$bar2 = 201}{", $modifiers, "}", "{debug_dump( \$bar )},{debug_dump( \$bar2 )}]\n"));
$list = perm("%num%:", $main);
// special tests
// $a == $b == $c (should produce proper PHP code ) => ($a == $b) == $c
// $a = $b = $c (should produce proper PHP code) $a = ($b = $c)
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/binary_operators.in", $argv);
$objCode = "if ( !class_exists( 'ezcTemplateTestExprMyClass', false ) )\n" . "{\n" . "  class ezcTemplateTestExprMyClass\n" . "  {\n" . "    public \$foo = 301;\n" . "  }\n" . "}\n" . "\$obj = new ezcTemplateTestExprMyClass();\n";
$objCodeSend = $objCode . "\$v = new ezcTemplateVariableCollection();\n" . "\$v->obj = \$obj;\n" . "return \$v;\n";
$i = 1;
$top = "{use \$obj}\n{var \$foo = 42, \$bar = 101, \$bar2 = 201, \$arr = array( 'foo' => 401 )}\n";
$topPHP = "\$foo = 42; \$bar = 101; \$bar2 = 201; \$arr = array( 'foo' => 401 );\n";
$phpCode = '';
$fileOut = $dir . "expressions/correct/binary_operators.out";
$filePHP = $dir . "expressions/correct/binary_operators.php";
$fileSend = $dir . "expressions/correct/binary_operators.send";
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/blocks/correct/delimiter_with_loop.in
$loopTypes = altMaster(altSlave("{foreach 1..10 as \$b}\n", "{\$b = 1}\n{while \$b <= 10}\n"), altSlave("{/foreach}\n", "  {\$b++}\n{/while}\n"));
$list = perm("{foreach 1..4 as \$a", alt("", " offset 1", " limit 1", " offset 1 limit 1"), "}\n", indent(perm("{\$a}\n", "{delimiter", alt("", " modulo 3"), "}\n", indent(perm($loopTypes, "  :{\$b}:\n", $loopTypes->slaves[1]), "  "), "{/delimiter}\n"), "  "), "{/foreach}\n", "============\n");
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("blocks/correct/delimiter_with_loop.in", $argv);
$i = 1;
$a->output("{var \$a = 0, \$b = 0}\n");
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $a->output($str);
    //    $a->store( "mock:2:2: Unknown block <{$name}>.\n" .
    //               "\n" .
    //               "{{$name}}\n" .
    //               " ^\n",
    //               $fileOut );
    ++$i;
} while ($list->increase());
$a->close();
Пример #25
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/literals/array_create_with_comments3.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$list = perm('debug_dump( array', '(', alt(perm(clone $comments, '0', clone $comments, ',', clone $comments, '1', clone $comments)), ') )');
$a = app("literals/array_create_with_comments3.in", $argv);
do {
    $str = $list->generate();
    $a->output("{" . $str . "}\n");
} while ($list->increase());
Пример #26
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/if/correct/if_nested.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$empty = alt('');
$if = perm("{if \$_foo}", "\n    {\$_foo}\n", "{/if}\n");
$ifElse = perm("{if \$_false}", "\n    {\$_foo}\n", "{else}", "\n    {\$_bar}\n", "{/if}\n");
$ifElseIf = perm("{if \$_false}", "\n    {\$_foo}\n", "{elseif \$_true}", "\n    {\$_bar}\n", "{/if}\n");
$ifElseIfElse = perm("{if \$_false}", "\n    {\$_foo}\n", "{elseif \$_true}", "\n    {\$_bar}\n", "{else}", "\n    {\$_false}\n", "{/if}\n");
$ifElseIfElse2 = perm("{if \$_false}", "\n    {\$_foo}\n", "{elseif \$_true}", "\n    {\$_bar}\n", "{elseif \$_false}", "\n    {\$_bar}\n", "{else}", "\n    {\$_false}\n", "{/if}\n");
$ifNested = perm("{if \$_foo}\n", altI('--->', clone $empty, clone $if, clone $ifElse, clone $ifElseIf, clone $ifElseIfElse, clone $ifElseIfElse2), "{/if}\n");
$ifNested2 = perm("{if \$_foo}\n", altI('===>', clone $if, clone $ifElse, clone $ifElseIf, clone $ifElseIfElse, clone $ifElseIfElse2, clone $ifNested), "{/if}");
$list = perm(clone $if, clone $ifElse, clone $ifElseIf, clone $ifElseIfElse, clone $ifElseIfElse2, clone $ifNested2);
$a = app("if/correct/if_nested.in", $argv);
$a->output("{var \$_foo = \"foo\",\n     \$_bar = \"bar\",\n     \$_false = false,\n     \$_true = true}\n");
do {
    $str = $list->generate();
    $a->output($str . "\n");
} while ($list->increase());
Пример #27
0
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/array_append/append_with_comments.in
$ws = alt("", " \t", "\n");
$comment = alt("/*c*/", "//c\n");
$wsComment = alt(clone $ws, clone $comment, clone $ws);
$comments = alt(clone $ws, clone $comment);
$list = perm(alt('$a'), clone $comments, alt('['), clone $comments, alt(']'), clone $comments, alt('=1'));
$a = app("array_append/append_with_comments.in", $argv);
$a->output("{var \$a = array( 0 )}\n");
do {
    $str = $list->generate();
    $a->output("{" . $str . "}\n");
} while ($list->increase());
$a->output("{debug_dump( \$a )}\n");
require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/expressions/correct/binary_operators_*.in
$binOperators = alt("+", "-", "*", "/", "%", "==", "===", "!=", "!==", "<", "<=", ">", ">=", "&&", "||", ".");
$binOperators2 = clone $binOperators;
$binOperators3 = clone $binOperators;
$binOperators4 = clone $binOperators;
$objectOperators = alt("->");
$constValues = alt("5", "-\$foo");
$bin = perm(clone $constValues, " ", $binOperators2, " ", clone $constValues);
$object = perm("\$obj", " ", $objectOperators, " ", "foo");
$array = perm("\$arr['foo']");
$bin2 = perm("\$foo", " ", $binOperators3, " ", 5);
$comboLeft = alt(clone $bin2, $object, $array);
$binCombination = perm(alt("( ", "!( "), $comboLeft, " ) ", $binOperators4, " ", clone $constValues);
$bins = alt($bin, $binCombination);
$main = alt(perm("[{debug_dump( ", $bins, " )}]\n"));
$list = perm("%num%:", $main);
// special tests
// $a == $b == $c (should produce proper PHP code ) => ($a == $b) == $c
// $a = $b = $c (should produce proper PHP code) $a = ($b = $c)
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/binary_operators_0001.in", $argv);
$objCode = "if ( !class_exists( 'ezcTemplateTestBinOpMyClass', false ) )\n" . "{\n" . "  class ezcTemplateTestBinOpMyClass\n" . "  {\n" . "    public \$foo = 301;\n" . "  }\n" . "}\n" . "\$obj = new ezcTemplateTestBinOpMyClass();\n";
$objCodeSend = $objCode . "\$v = new ezcTemplateVariableCollection();\n" . "\$v->obj = \$obj;\n" . "return \$v;\n";
$i = 1;
$topObj = "{use \$obj}\n";
$top = "{var \$foo = 42, \$bar = 101, \$bar2 = 201, \$arr = array( 'foo' => 401 )}\n";
$topPHP = "\$foo = 42; \$bar = 101; \$bar2 = 201; \$arr = array( 'foo' => 401 );\n";
$phpCode = array(1 => '');
$sendMap = array(1 => false);
$block = 1;
<?php

require_once dirname(__FILE__) . "/permutation.php";
// Writes to: regression_tests/expressions/correct/modifying_operators_*.in
$modifyingOperators = alt("=", "+=", "-=", "*=", "/=", "%=", ".=");
$constValues = alt("5", "-\$foo");
$modify = perm("\$bar", " ", $modifyingOperators, alt(perm(alt("", perm(" \$bar2 ", clone $modifyingOperators)), " ", 5)));
$modifiers = alt($modify);
$main = alt(perm("[{\$bar = 101}{\$bar2 = 201}{", $modifiers, "}", "{str_number( \$bar, 5, ',', '' )},{str_number( \$bar2, 5, ',', '' )}]\n"));
$list = perm("%num%:", $main);
// special tests
// $a == $b == $c (should produce proper PHP code ) => ($a == $b) == $c
// $a = $b = $c (should produce proper PHP code) $a = ($b = $c)
$dir = dirname(__FILE__) . "/../regression_tests/";
$a = app("expressions/correct/modifying_operators.in", $argv);
$objCode = "if ( !class_exists( 'ezcTemplateTestModOpMyClass', false ) )\n" . "{\n" . "  class ezcTemplateTestModOpMyClass\n" . "  {\n" . "    public \$foo = 301;\n" . "  }\n" . "}\n" . "\$obj = new ezcTemplateTestModOpMyClass();\n";
$i = 1;
$top = "{var \$foo = 42, \$bar = 101, \$bar2 = 201, \$arr = array( 'foo' => 401 )}\n";
$topPHP = "\$foo = 42; \$bar = 101; \$bar2 = 201; \$arr = array( 'foo' => 401 );\n";
$phpCode = '';
$fileOut = $dir . "expressions/correct/modifying_operators.out";
$filePHP = $dir . "expressions/correct/modifying_operators.php";
$a->output($top);
do {
    $num = sprintf("%04d", $i);
    $str = $list->generate();
    $str = str_replace("%num%", $num, $str);
    $fileIn = $dir . "expressions/correct/modifying_operators_" . $num . ".in";
    $a->output($str);
    if ($main->index == 0) {
        $phpCode .= "\$bar = 101; \$bar2 = 201;\n" . $modifiers->generate() . ";\n" . "echo '{$num}:[', number_format( \$bar, 5, ',', '' ), ',', number_format( \$bar2, 5, ',', '' ), \"]\\n\";\n";
Пример #30
0
	<tr class="<?=stripes()?>">
		<td class="right"><?=$ballot->id?></td>
		<td><?=h($ballot->name)?></td>
		<td><?=$ballot->ngroup()->name?></td>
		<td class="center"><?=timeformat($ballot->opening)?> &ndash; <?=BALLOT_CLOSE_TIME?></td>
		<td><?=h($ballot->agents)?></td>
		<td class="center"><?=$ballot->voters?></td>
<?
		if ($entitled) {
?>
		<td>
<?
			/** @noinspection PhpUndefinedVariableInspection */
			if ($row_voters and $row_voters['ballot']==$ballot->id) {
				if ($row_voters['agent']) {
					?><a href="ballot_edit.php?id=<?=$ballot->id?>" class="icontextlink"><img src="img/edit.png" width="16" height="16" <?alt(_("edit"))?>><?=_("You are agent for this ballot.")?></a><?
				} else {
					?>&#10003; <?=_("You selected this ballot for voting.");
				}
				if ($period->state!="ballot_preparation") {
					form("", 'class="button"');
?>
<input type="hidden" name="action" value="unselect">
<input type="submit" value="<?=_("remove selection")?>">
<?
					form_end();
				}
			} elseif (
				$show_select and (
					$period->state=="ballot_application" or
					($period->state=="ballot_assignment" and $ballot->approved)