This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
/
subs.cfg
347 lines (319 loc) · 6.72 KB
/
subs.cfg
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
UserTag check-file Order file flags
UserTag check-file PosNumber 2
UserTag check-file Routine <<EOR
use strict;
sub {
my ($files, $flags) = @_;
$flags = 'dw' unless $flags;
my(@files) = grep /\S/, split /\s+/, $files;
my(@flags) = grep /[dwrfxluzse]/, split //, $flags;
my ($result, $file);
foreach $file (@files) {
for(@flags) {
eval "\$result = -$_ '$file'";
next if $result;
$::Values->{mv_error_file_test} = "-$_ $file not passed.";
return undef;
}
}
return 1;
}
EOR
UserTag embed HasEndTag 1
UserTag embed Routine <<EOR
sub {
my $code = shift;
my ($result, $error);
eval {
($result, $error) = eval $code;
};
if($@) {
$::Values->{mv_error_embed} = "Syntax? error: $@\nfrom code:\n $code";
return undef;
}
$::Values->{mv_error_embed} = $error || undef;
return $result;
}
EOR
UserTag cat-param Order name param;
UserTag cat-param PosNumber 2
UserTag cat-param Routine <<EOR
sub {
my ($name, $param) = @_;
my $g;
return undef unless $g = $Global::Catalog{$name};
if($param) {
return $g->{$param};
}
else {
return join " ", $name, $g->{'dir'}, $g->{script}, $g->{aliases};
}
}
EOR
UserTag listcats Routine <<EOR
sub {
return join "\n", grep $_ ne '_mv_admin', sort keys %Global::Catalog;
}
EOR
UserTag additional AddAttr
UserTag additional Order template
UserTag additional PosNumber 1
UserTag additional Routine <<EOR
sub {
my ($dir, $opt) = @_;
$opt = {} if ! $opt;
ADDITIONAL: {
last ADDITIONAL if $opt->{'name'} and
defined $::Scratch->{MVC_HELP};
unless ($dir =~ m{(?:[A-Z]:)?[/\\]} ) {
$dir = "$Global::VendRoot/$dir";
}
return '' unless -f "$dir/config/additional_fields";
open(ADDL, "$dir/config/additional_fields")
or return '';
my @var;
my %help;
my %prompt;
my %default;
local ($/) = "";
if(open(ADDLHELP, "$dir/config/additional_help") ) {
while(<ADDLHELP>) {
my($parm,$help) = split /\n/, $_, 2;
$help =~ s/\s*$/\n\n/;
$help{uc $parm} = $help;
}
close ADDLHELP;
}
while(<ADDL>) {
s/\s+$//;
s/__MVC_([A-Z0-9]+)__/$::Values->{$1}/eg;
my ($var, $prompt, $default) = split /\n/, $_, 3;
$var =~ s/\s+//g;
$var = uc $var;
push @var, $var;
$prompt{$var} = $prompt;
$default{$var} = $default;
if (defined $help{$var}) {
$help{$var} =~ s/__MVC_([A-Z0-9]+)__/$::Values->{$1}/eg;
}
}
close ADDL;
$::Scratch->{MVC_HELP} = \%help;
$::Scratch->{MVC_VAR} = \@var;
$::Scratch->{MVC_PROMPT} = \%prompt;
$::Scratch->{MVC_DEFAULT} = \%default;
}
if($opt->{'name'}) {
my $name = uc $opt->{'name'};
return $::Scratch->{MVC_HELP}{$name}
if $opt->{'help'};
return $::Scratch->{MVC_PROMPT}{$name}
if $opt->{'prompt'};
return $::Scratch->{MVC_DEFAULT}{$name} || ' '
if $opt->{'default'};
}
else {
return "" if ! $::Scratch->{MVC_VAR};
return join " ", @{$::Scratch->{MVC_VAR}};
}
}
EOR
UserTag makecat Order seed
UserTag makecat Routine <<EOR
sub {
my $test = shift;
my @session = ( qw/
address
aliases
basedir
catalogname
catroot
catuser
cgibase
cgidir
cgiurl
city
company
documentroot
encryptor
fax
homedir
imagedir
imageurl
linkmode
linkprogram
logo
mailorderto
minivendgroup
minivenduser
nocfg
norunning
phone
samplehtml
sampleurl
serverconf
servername
shipmodes
smlogo
template
tollfree
vendroot
/);
my %server = ( qw/
aliases 1
basedir 1
catalogname 1
catroot 1
catuser 1
cgibase 1
cgidir 1
cgiurl 1
demotype 1
template 1
documentroot 1
imagedir 1
homedir 1
imageurl 1
linkmode 1
linkprogram 1
mailorderto 1
minivendgroup 1
minivenduser 1
nocfg 1
nocopy 1
norunning 1
reference 1
samplehtml 1
sampleurl 1
serverconf 1
servername 1
vendroot 1
/);
if(defined $::Scratch->{MVC_VAR}) {
push @session, map { lc $_ } @{$::Scratch->{MVC_VAR}};
}
my %seen;
@session = grep ! $seen{$_}++, @session;
my %implicit = qw/nocfg 1 norunning 1/;
my @parms;
if($test) {
@parms = grep /\S/, split /\s+/, $test;
for(@parms) {
$_ = lc $_;
}
}
else {
@parms = @session;
}
my $die = sub {
$::Values->{mv_error_makecat_message} .= join "\n", @_;
return undef;
};
$::Values->{mv_error_makecat_message} = '';
my $script = "$Global::VendRoot/bin/makecat";
return &$die("No makecat program available.") unless -x $script
or $^O =~ /win32/i;
my @cmdline;
my $val;
my $parm;
foreach $parm (@parms) {
next unless defined ($val = $::Values->{"\U$parm"});
my $prefix = defined $server{$parm} ? '--' : '';
unless ($val =~ m!^[-\w/:.]+$! ) {
$val =~ s/"/\\"/g;
$val = qq{"$val"};
}
if( defined $implicit{$parm} ) {
next unless $val;
}
else {
next if ! $val and ! $prefix;
$val = '=' . $val;
}
push @cmdline, qq{$prefix$parm$val};
}
push @cmdline, ($test ? "--reference" : "-F");
unshift @cmdline, $script;
if($^O =~ /win32/i) {
unshift @cmdline, $Config::Config{perlpath};
}
my $string = join " ", @cmdline;
open(ERRLOG, ">makecat.errors") or die "create makecat.errors: $!\n";
open(STDERR, ">&ERRLOG") or die "dup STDERR: $!\n";
my $save_umask = umask(0);
if($test) {
local($/) = undef;
my $save_umask = umask(0);
open(CMD, "$string |")
or return &$die("cannot fork: $!");
my $safe = new Safe;
my $ref = $safe->reval(<CMD>);
close CMD;
if($@ or ! ref $ref) {
umask $save_umask;
my $msg = Vend::Util::readfile('makecat.errors');
return &$die(<<EOErrors);
Catalog test run failed. [page seefile#bottom makecat.log]See log.[/page]
<PRE>
Immediate errors:
----------------
$msg
</PRE>
EOErrors
}
else {
$Vend::Session->{makecat_ref} = $ref;
}
my ($k, $v);
for (@session) {
$k = $_;
$k = 'demotype' if $k eq 'template';
next unless defined $ref->{$k};
$v = $ref->{$k};
$::Values->{"\U$_"} = $v;
}
}
else {
system($string);
umask $save_umask;
#system(@cmdline);
if($?) {
my $msg = Vend::Util::readfile('makecat.errors');
return &$die(<<EOErrors);
Catalog build failed. [page seefile#bottom makecat.log]See log.[/page]
<PRE>
Immediate errors:
----------------
$msg
</PRE>
EOErrors
}
if(! $Global::Windows) {
sleep $Global::HouseKeeping
if $Global::HouseKeeping < 11;
}
}
#if(defined $extra_file) {
# open(ERR, $extra_file) or die "open extra_file: $!";
# $extra = <ERR>;
# close ERR;
# unlink $extra_file;
#}
return 1;
}
EOR
UserTag global-value Order name
UserTag global-value Routine <<EOR
sub {
no strict 'refs';
defined ${$_[0]} and return ${$_[0]};
return '';
}
EOR
UserTag wizard order current next back cancel fail default routine
UserTag wizard HasEndTag 1
UserTag wizard Routine <<EOR
sub {
1;
}
EOR