[set page_title]Mass setting of set/seti/tmp/tmpn settings[/set] @_UI_STD_HEAD_@ [calc] return if $CGI->{pattern}; $CGI->{pattern} = '*'; $CGI->{setting} = $Variable->{DEFAULT_MASS_SETTING} || 'ads_top'; $CGI->{dontdo} = 1; return; [/calc] [form-session-id]
[display type=select name=setting value="[cgi setting]" passed="[either]__MASS_SETTINGS__[or]ads_top,ads_left,page_title,members_only[/either]" ] File name pattern to scan [form-session-id] [perl] my @pages = grep /^dopage\d+$/, keys %$CGI; my @do; for(@pages) { #Debug("Checking $_"); next unless $CGI->{$_}; #Debug("$_ is changable."); my $digits = $_; $digits =~ s/^dopage//; push @do, $digits; } return unless @do; for(@do) { my $page = $CGI->{"page$_"}; my $settor = $CGI->{"settor$_"}; my $val = $CGI->{"value$_"}; #Debug("ready to write page=$page settor=$settor val=$val"); my $data = $Tag->file("pages/$page", 'raw'); $data =~ s/(\n[ \t]*\@_[A-Z][A-Z_]+_\@[ \t]*\n.*)//s or do { $Tag->warnings("page $_ not a templated page."); next; }; my $tail = $1; $data =~ s{ \[ (seti?|tmpn?) \s+ $CGI->{setting} \s* \] (.*?) \[/ \1 ] } {[$settor $CGI->{setting}]$val\[/$settor]}xs or $data =~ s{ (\[ (seti?|tmpn?) \s+ \w+ \s* \] (.*?) \[/ \2 ]) } {$1\n[$settor $CGI->{setting}]$val\[/$settor]}xs or $data =~ s{(\s*)$}{\n[$settor $CGI->{setting}]$val\[/$settor]\n$1}s or do { $Tag->warnings("$page didn't match."); next; }; $Tag->write_relative_file("pages/$page", $data . $tail); $Tag->warnings("Wrote page $page.
"); } [/perl] [warnings auto=1]

[calc] my $items; return if $CGI->{dontdo}; my $suf = $Config->{HTMLsuffix}; if($CGI->{pattern} eq '*') { $items = $Tag->list_pages({ arrayref => 1 }); for(@$items) { $_ .= $suf; } } else { my @pats = split /[\s\0]+/, $CGI->{pattern}; my @items; for(@pats) { push @items, $Tag->list_glob("pages/$_"); } for(@items) { s{^pages/}{}; } my $pat = $suf; $pat = "\\$pat\$"; my $re = qr/$pat/; @items = grep $_ =~ $re, @items; $items = \@items; } my $setre = "\\[(seti?|tmpn?)\\s+$CGI->{setting}\\s*\\](.*?)\\[/\\1\\]"; $setre = qr($setre); my @things; for(@$items) { my $data = $Tag->file("pages/$_", 'raw'); $data =~ s/\n[ \t]*\@_[A-Z][A-Z_]+_\@[ \t]*\n.*//s or do { $Tag->warnings("page $_ not a templated page."); next; }; $data =~ $setre or do { push @things, { page => $_, settor => undef, current => '', }; next; }; push @things, { page => $_, settor => $1, current => $2, }; } my $settor_passed = 'set,seti,tmp,tmpn'; my @out; my $i = '0000'; for my $ref (@things) { $i++; push @out, "

"; push @out, qq{}; push @out, qq{}; push @out, "$ref->{page}"; my $extra = qq{onChange="this.form.dopage$i.checked = true"}; push @out, "

"; push @out, $Tag->display({ name => "settor$i", type => 'select', passed => $settor_passed, value => $ref->{settor}, js => $extra, }); push @out, "

"; my $w; my $h; my $wid; if($ref->{current} =~ /[\r\n]/) { $w = 60; $h = 3; $wid = 'textarea'; } else { $w = 60; $wid = 'text'; } push @out, $Tag->display({ name => "value$i", type => $wid, height => $h, width => $w, value => $ref->{current}, extra => $extra, }); push @out, "

"; } ## Put the global settors push @out, "

"; push @out, "
Apply this to all"; push @out, " | "; push @out, $Tag->display({ name => "allsettor", type => 'select', passed => $settor_passed, }); push @out, " | "; push @out, $Tag->display({ name => "allvalue", type => 'text', width => 60, }); push @out, qq{}; push @out, qq{}; push @out, "
"; $CGI->{change_button} = 1; return join "", @out; [/calc] [if cgi change_button]
When ready.... |
[/if]

@_UI_STD_FOOTER_@