-
Notifications
You must be signed in to change notification settings - Fork 0
/
output_php.def
106 lines (93 loc) · 2.76 KB
/
output_php.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
include: output.def
include: macros_output/for.def
include: macros_www/tags.def
page: output_php, output_main
type: pm
output_dir: lib/MyDef
ext: php
package: MyDef::output_php
subcode:: init_page
$global %php_globals, @php_globals
%php_globals=()
@php_globals=()
subcode:: dumpout
$if @php_globals
$foreach $v in @php_globals
push @$f, "$v;\n"
#-----------------------------------------------
fncode: php_print($s)
$s=~s/"/\\"/g
return "echo \"$s\";"
#-----------------------------------------------
subcode: parsecode
$call parsecode_common
subcode: parsecode_special
$case $l=~/^CSS:\s*(.*)/
return MyDef::output_www::parse_css($1)
subcode: parsecode_other
$if $l!~/[\{\};]\s*$/
$l.=";";
subcode: parsecode_func_param
subcode: parsecode_func
$call parsecode_html_tag, php_print
$if $func =~/^echo/
push @$out, php_print($param)
return
$elif $func =~/^if(\w*)/
$if $1 and $param!~/^!/
$param=test_var($param, $1 eq 'z')
return single_block("if($param){", "}")
$elif $func =~ /^(el|els|else)if(\w*)$/
$if $2 and $param!~/^!/
$param=test_var($param, $2 eq 'z')
return single_block("elseif($param){", "}")
$elif $func eq "else"
return single_block("else{", "}")
$elif $func eq "for"
$call parsecode_for_support, c_style
$elif $func eq "foreach" or $func eq "for" or $func eq "while"
return single_block("$func ($param){", "}")
$elif $func eq "function"
return single_block("function $param {", "}")
$elif $func eq "global"
$param=~s/\s*;\s*$//
my @tlist=MyDef::utils::proper_split($param)
$foreach $v in @tlist
$if !$php_globals{$v}
$php_globals{$v}=1
push @php_globals, $v
$v=~s/=.*//
push @$out, "global $v;"
return
$elif $func eq "print"
my $str=$param
$if $str=~/^\s*\"(.*)\"\s*$/
$str=$1
push @$out, php_print($str)
return
subcode: for_i0_i1_step
$call for_i0_i1_step_default, loop_var
subcode: loop_var
$if !$var
$var="\$i"
$elif $var=~/^(\w+)/
$var='$'.$var
#-----------------------------------------------
fncode: echo_php($t, $ln)
$t=~s/\\/\\\\/g
$t=~s/"/\\"/g
$if $ln
return "echo \"$t\\n\";";
$else
return "echo \"$t\";";
fncode: test_var($param, $z)
$if $param=~/(\$\w+)\[(^[\]]*)\]/
$if !$z
return "array_key_exists($2, $1) and $param"
$else
return "!(array_key_exists($2, $1) and $param)"
$else
$if $z
return "empty($param)"
$else
return "!empty($param)"