Contents ::
|
|
package k2;
;;;;;;;;;; use Switch;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sub FONTH{
my ($lh) = @_;
if($lh eq ''){
return('</FONT>');
}else{
return('<FONT style="'."line-height: $lh%".'">');
}
}
sub INDENT{
my ($id) = @_;
if(@_[0] eq ''){
return('</DIV>');
}else{
return('<DIV style="text-indent: 0em; padding-left: '.$id.'em">');
}
}
sub LIST{
my ($ul, @dt) = @_;
my($tag, @lst);
unless($ul){
$tag = 'UL';
$ul = 'disc';
}else{
if(PosStr($ul, '1 a A i I') > 0){
$tag = 'OL';
}else{
$tag = 'UL';
$ul = lc($ul);
$ul = 'disc' if(PosStr($ul, '1d'));
$ul = 'circle'if(PosStr($ul, '2c'));
$ul = 'square'if(PosStr($ul, '3s'));
}
}
push(@lst, "<$tag type='$ul'>");
foreach(@dt){
push(@lst, "\t<LI>$_</LI>");
}
push(@lst, "</$tag>");
return(@lst);
}
sub RUBY{
my ($rb, $rt) = @_;
my $ret = "<RUBY><RB>$rb<RP>(<RT>$rt<RP>)</RUBY>";
return($ret);
}
sub SUB{
my ($s) = @_;
my ($p, $a, $b);
do{
$p = PosStrW('\_', $s);
if($p){
$a = LeftStrW($s, $p - 1).'<SUB>';
$b = MidStrW($s, $p + 2, 1).'</SUB>';
$s = $a.$b.RightStrW($s, LengthW($s) - $p - 2);
}
}while($p);
do{
$p = PosStrW('\~', $s);
if($p){
$a = LeftStrW($s, $p - 1).'<SUP>';
$b = MidStrW($s, $p + 2, 1).'</SUP>';
$s = $a.$b.RightStrW($s, LengthW($s) - $p - 2);
}
}while($p);
return($s);
}
sub FONT{
my ($fs, $fc, $bg, $fn, $cs) = @_;
if($fn.$fs.$fc.$bg.$cs eq ''){
return('</SPAN>');
}else{
if($fn){
$fn = fixFont($fn);
$fn = "font-family: $fn; "
}
$fs = "font-size: $fs; " if($fs);
$fc = "color: $fc; " if($fc);
$bg = "background-color: $bg; "if($bg);
$cs = ' '.$cs if($cs);
my $css = '<SPAN style="'.Trim($fn.$fs.$fc.$bg.$cs).'">';
return($css);
}
}
sub FONT1{
my ($fn, $fc, $fs) = @_;
if($fn eq ''){
return('</FONT>');
}else{
$fn = fixFont($fn);
my $fnt = "<FONT face='$fn' size=$fs color='$fc'>";
return($fnt);
}
}
sub IMG{
my ($fl, $bd, $wd, $ht, $al, $cs) = @_;
($wd, $ht) = ImgSize($fl) if($wd eq '?');
$bd = '0' unless($bd);
$al = 'alt="'.$al.'" ' if($al);
$wd = 'width="'.$wd.'" ' if($wd);
$ht = 'height="'.$ht.'" ' if($ht);
my $img = '<IMG src="'.$fl.'" '.$al.$wd.$ht.'border="'.$bd.'">';
return($img);
}
sub EMBED{
my ($fl, $rp, $bd, $wd, $ht) = @_;
$bd = '0' unless($bd);
$wd = 'width="'.$wd.'" ' if($wd);
$ht = 'height="'.$ht.'" ' if($ht);
$rp = 'loop = "true" repeat="'.$rp.'" ' if($rp);
my $ct = 'control="smallconsole" ';
my $emb = '<EMBED src="'.$fl.'" autostart="true" '.$ct.$rp.$wd.$ht.'border="'.$bd.'">';
$emb .= '<NOEMBED>プラグインで来ませんでした!!</NOEMBED>';
return($emb);
}
sub MARQUEE{
my ($s, $dr, $d1, $d2, $d3) = @_;
my ($bh, $ht, $bg, $m1, $m2, $ret);
$dr = MinMax($dr, 1, 4);
if($dr eq '3' || $dr eq '4'){
$ht = $d1;
$bh = $d2;
$bg = $d3;
}else{
$bh = $d1;
$bg = $d2;
}
switch($dr){
case 1 {$m1 = 'direction="right" '}
case 2 {$m1 = 'direction="left" '}
case 3 {$m1 = 'direction="up" '}
case 4 {$m1 = 'direction="down" '}
}
switch(MinMax($bh, 1, 3)){
case 1 {$m2 = 'behavior="scroll" '}
case 2 {$m2 = 'behavior="alternate" '}
case 3 {$m2 = 'behavior="slide" '}
}
$ht = 'height="'.$ht.'" ' if($ht);
$bg = 'bgcolor="'.$bg.'"' if($bg);
$ret = "<MARQUEE $m1$m2$ht$bg>$s</MARQUEE>";
return($ret);
}
sub FILTER{
my ($ef, $v1, $v2, $v3, $v4) = @_;
if($ef eq ''){
return('</SPAN>');
}else{
my (@ff, $tg);
@ff = (
'glow(strength='.$v1.',color='.$v2.')' ,
'dropshadow(offx='.$v1.',offy='.$v1.',color='.$v2.')' ,
'shadow(direction='.$v1.',color='.$v2.')' ,
'blur(add=0,direction='.$v1.',strength='.$v2.')' ,
'wave(add=0,freq='.$v1.',phase='.$v2.',strength='.$v3.',lightstrength='.$v4.')' ,
'Alpha(opacity='.$v1.')' ,
'Chroma(color='.$v1.')' ,
'Mask(color='.$v1.')' ,
'Gray()' ,
'Xray()' ,
'FlipH()' ,
'Flipv()' ,
'Invert()'
);
$ef = MinMax($ef, 1, 13) - 1;
$tg = '<SPAN style="width:100%; filter: '.$ff[$ef].';">';
return($tg);
}
}
sub DIV{
my ($al, $mg, $pd, $wd, $px, $ps, $cl, $bc, $cs) = @_;
if($al eq ''){
return('</DIV>');
}else{
my $align = 'center';
my $s = lc(LeftStr($al, 1));
$align = 'left' if(PosStr($al, '0l'));
$align = 'center' if(PosStr($al, '1c'));
$align = 'right' if(PosStr($al, '2r'));
$align = 'justify' if(PosStr($al, '3j'));
$al = $align;
unless($mg.$pd.$wd.$px.$cl.$bc.$cs){
return("<DIV align='$al'>");
}else{
$wd = 'width:'.$wd.'; ' if($wd ne '');
$mg = 'margin:'.$mg.'px; ' if($mg ne '');
$pd = 'padding:'.$pd.'px; 'if($pd ne '');
if($px ne '' && $cl ne ''){
$px = 'border:'.$px.'px ';
if($cl ne ''){
my @bs = ('solid', 'dotted', 'dashed');
$ps = MinMax($ps, 0, 2);
$px .= $bs[$ps].' '.$cl.'; ';
}
}else{
$px = '';
$cl = '';
}
if($bc ne ''){
$bc = "background-color:$bc";
}
$cs = ' '.$cs if($cs);
my $div = TrimR($mg.$pd.$wd.$px.$bc.$cs);
if($div){
$div = "<DIV align='".$al."'".' style="'.$div.'">';
}else{
$div = "<DIV align='".$al."'>";
}
return($div);
}
}
}
sub TABLE{
my ($sw, $lc, $tt, $ft, @dt) = @_;
my ($cs, $bd, $mw, $tb, $d3, @tb, @wd, @cl, @fc, @al, %hc, %hf, %hv);
$sw = MinMax($sw, 0, 5);
switch($sw){
case 0 {$cs = 0; $bd = 0}
case 1 {$cs = 1; $bd = 0}
case 2 {$cs = 1; $bd = 1}
case 3 {
$cs = 1; $bd = 0;
$d3 = 'style="border-width: 1px 1px; border-style: solid; ';
$d3 .= 'border-color: #9999CC #333366 #333366 #9999CC;" '
}
case 4 {
$cs = 1; $bd = 0;
$d3 = 'style="border-style: solid; border-width: 1px 0px;" ';
$tb = 'style="border-collapse: collapse; border-style: solid;';
$tb .= ' border-width: 1px; border-color: '.$lc.';" ';
}
case 5 {
$cs = 1; $bd = 0;
$d3 = 'style="border-style: solid; border-width: 0px 1px;" ';
$tb = 'style="border-collapse: collapse; border-style: solid;';
$tb .= ' border-width: 1px; border-color: '.$lc.';" ';
}
}
unless($tb){
$tb = "cellspacing=$cs cellpadding=3 border=$bd bgcolor=$lc";
}
if($dt[0][0] eq '/'){
DeleteOf(\@dt, 0, 1);
unless($dt[0][0] eq '/'){
@wd = @{$dt[0]};
for(my $j = 0; $j < @wd; $j++){
$mw += $wd[$j];
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
@al = @{$dt[0]};
for(my $i = 0; $i < @al; $i++){
my $v = LeftStr(lc(@al[$i]), 1);
my $s = 'center';
$s = 'left' if(PosStr($v, '0l'));
$s = 'center'if(PosStr($v, '1c'));
$s = 'right' if(PosStr($v, '2r'));
@al[$i] = $s;
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
@cl = @{$dt[0]};
for(my $i = 0; $i < @cl; $i++){
@cl[$i] = 'white' unless(@cl[$i]);
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
my @wk = @{$dt[0]};
for(my $i = 0; $i < @wk; $i++){
my @r = CutOff(':', $wk[$i]);
$hc{$r[0]} = $r[1];
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
@fc = @{$dt[0]};
for(my $i = 0; $i < @fc; $i++){
@fc[$i] = 'black' unless(@fc[$i]);
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
my @wk = @{$dt[0]};
for(my $i = 0; $i < @wk; $i++){
my @r = CutOff(':', $wk[$i]);
$hf{$r[0]} = $r[1];
}
DeleteOf(\@dt, 0, 1);
}
unless($dt[0][0] eq '/'){
my @wk = @{$dt[0]};
for(my $i = 0; $i < @wk; $i++){
my @r = CutOff(':', $wk[$i]);
my $v = LeftStr(lc(@r[1]), 1);
my $s = 'center';
$s = 'top' if(PosStr($v, '0t'));
$s = 'center' if(PosStr($v, '1c'));
$s = 'bottom' if(PosStr($v, '2b'));
$hv{$r[0]} = $s;
}
DeleteOf(\@dt, 0, 1);
}
for(my $i = 0; $i < @dt; $i++){
if($dt[$i][0] eq '/'){
DeleteOf(\@dt, 0, $i + 1);
last;
}
}
}else{
for(my $i = 0; $i < @dt; $i++){
push(@cl, 'white');
push(@al, 'center');
}
}
push(@tb, "<TABLE $tb>");
my ($s, $wf, $hf, $ln, $mx, $cc, $fc, $al, $vl, $td);
push(@tb, "\t<CAPTION>$tt</CAPTION>")if($tt);
for(my $i = 0; $i < @dt; $i++){
$ln = @{$dt[$i]};
$mx = $ln if($ln > $mx);
if($i == 0){
for(my $j = 0; $j < @{$dt[$i]}; $j++){
$s .= $dt[$i][$j];
}
}
}
$hf = ($s) ? 1 : 0;
DeleteOf(\@dt, 0, 1) unless($hf);
if($hf){
push(@tb, "\t<THEAD>");
$ln = @{$dt[0]};
$wf = 1 if($ln > 1);
if(exists($hv{0})){
$vl = $hv{0};
}else{
$vl = 'center';
}
push(@tb, "\t\t<TR valign='$vl'>");
for(my $j = 0; $j < $ln; $j++){
$s = Return2br($dt[0][$j]);
if(exists($hc{0})){
$cc = $hc{0};
}else{
$cc = ($cl[$j]) ? $cl[$j] : 'white';
}
if(exists($hf{0})){
$fc = $hf{0};
}else{
$fc = ($fc[$j]) ? $fc[$j] : 'black';
}
$td = $d3."bgcolor=$cc ";
if($ln == 1){
$td .= "colspan=$mx align=center width=$mw";
}else{
$td .= "align=$al[$j] width=$wd[$j]";
}
if($fc && index($s, '<FONT') < 0){
$s = "<FONT color=$fc>$s</FONT>";
}
push(@tb, "\t\t\t<TH $td>$s</TH>");
}
push(@tb, "\t\t</TR>");
push(@tb, "\t</THEAD>");
}
if($ft){
$cc = '#EEEEEE';
my @wk = CutOff(':', $ft);
$ft = $wk[0]if($wk[0] ne '');
$cc = $wk[1]if($wk[1] ne '');
$al = $wk[2]if($wk[2] ne '');
if($al){
$al = LeftStr(lc($al), 1);
$al = 'left' if(PosStr($al, '0l'));
$al = 'center'if(PosStr($al, '1c'));
$al = 'right' if(PosStr($al, '2r'));
}
$al = 'right' unless($al);
push(@tb, "\t<TFOOT>");
push(@tb, "\t\t<TR valign='center'>");
$td = $d3."align='$al' colspan=$mx bgcolor=$cc";
push(@tb, "\t\t\t<TD $td>$ft</TD>");
push(@tb, "\t\t</TR>");
push(@tb, "\t</TFOOT>");
}
push(@tb, "\t<TBODY>");
for(my $i = $hf; $i < @dt; $i++){
if(exists($hv{$i})){
$vl = $hv{$i};
}elsif(exists($hv{'?'})){
$vl = $hv{'?'};
}else{
$vl = 'center';
}
push(@tb, "\t\t<TR valign='$vl'>");
$ln = @{$dt[$i]};
for(my $j = 0; $j < $mx; $j++){
$s = Return2br($dt[$i][$j]);
my $fg = ($i - $hf) % 2;
if(exists $hc{$i}){
$cc = $hc{$i};
}else{
if($fg && exists($hc{'%'})){
$cc = $hc{'%'};
}elsif(exists($hc{'?'})){
$cc = $hc{'?'};
}else{
$cc = ($cl[$j]) ? $cl[$j] : 'white';
}
}
if(exists $hf{$i}){
$fc = $hf{$i};
}else{
if($fg && exists($hc{'%'})){
$fc = $hf{'%'};
}elsif(exists($hc{'?'})){
$fc = $hf{'?'};
}else{
$fc = ($fc[$j]) ? $fc[$j] : 'black';
}
}
$td = $d3."bgcolor=$cc align=$al[$j] ";
if($ln == 1){
last if($j > 0);
$td .= "colspan=$mx width=$mw";
}else{
$td .= "width=$wd[$j]"unless($wf);
}
if($fc && index($s, '<FONT') < 0){
$s = "<FONT color=$fc>$s</FONT>";
}
push(@tb, "\t\t\t<TD $td>$s</TD>");
}
push(@tb, "\t\t</TR>");
}
push(@tb, "\t</TBODY>");
push(@tb, "</TABLE>");
return(@tb);
}
;;;;;sub fep_{
my ($fep, $css) = @_;
my $ret = '';
if($fep ne ''){
my @fp = ('disabled', 'inactive', 'active');
$css = ($css) ? "; $css" : '';
$fep = MinMax($fep, 0, 2);
$ret = ' style="ime-mode: '.$fp[$fep].$css.'"';
}else{
$ret = ($css) ? ' style="'.$css.'"' : '';
}
return($ret);
}
sub InpGroup{
my ($txt, $aln, $sty) = @_;
if($txt.$aln eq ''){
return('</FIELDSET>');
}else{
my @al = ('left', 'center', 'right');
$aln = MinMax($aln, 0, 2);
$aln = $al[$aln]; $sty = fep_(0, $sty);
return("<FIELDSET$sty><LEGEND align='$aln'>$txt</LEGEND>");
}
}
sub InpMemo{
my ($nam, $col, $row, $txt, $fep, $rsw, $sty) = @_;
return('')unless($nam && $col && $row);
$sty = fep_($fep, $sty);
$rsw = ($rsw) ? ' readonly' : '';
my $ret = "<TEXTAREA name=$nam cols=$col rows=$row wrap='soft'$rsw$sty>$txt</TEXTAREA>";
return($ret);
}
sub InpForm{
my ($cgi, $tgt, $sty) = @_;
my $ret;
if($cgi.$sty eq ''){
$ret = '</FORM>';
}else{
$tgt = ($tgt eq '') ? '_self' : '';
$sty = ($sty) ? ' style="'.$sty.'"' : '';
$ret = "<FORM action='$cgi' target='$tgt' method='POST'$sty>";
}
return($ret);
}
sub InpText{
my ($typ, $nam, $siz, $max, $txt, $fep, $sty) = @_;
return('')unless($typ && $nam && $siz);
my @tp = ('text', 'password');
$typ = MinMax($typ, 1, 2) - 1;
$txt = ($txt) ? " value='$txt'" : " value=''";
$sty = fep_($fep, $sty);
$siz = ($siz) ? "size='$siz'" : '';
$max = ($max) ? " maxlength='$max'" : '';
my $ret = "<INPUT type='$tp[$typ]' name='$nam' $siz$max$txt$sty>";
return($ret);
}
sub InpCheck{
my ($typ, $nam, $val, $chk, $ptr, $sty) = @_;
return('')unless($nam && $val);
$typ = MinMax($typ, 0, 2);
my @tp = ('radio', 'checkbox', 'hidden');
if($typ < 2){
$chk = ($chk) ? ' checked' : '';
$sty .= ($ptr) ? ' cursor: pointer' : '';
}
$sty = fep_(0, Trim($sty));
my $ret = "<INPUT type='$tp[$typ]' name='$nam' value='$val'$chk$sty>";
return($ret);
}
sub InpButton{
my ($typ, $val, $siz, $ptr, $sty) = @_;
return('')unless($typ && $val && $siz);
my $ret;
$typ = MinMax($typ, 1, 3) - 1;
my @tp = ('file', 'submit', 'reset');
$sty .= ($ptr) ? ' cursor: pointer' : '';
$sty = fep_(0, Trim($sty));
if ($typ <= 2){
$ret = "<INPUT type='$tp[$typ]' value='$val'$ptr$sty>";
}else{
$ret = "<INPUT type='$tp[$typ]' name='$val' size='$siz'$sty>";
}
return($ret);
}
sub InpImage{
my ($nam, $alt, $img, $ptr, $sty) = @_;
return('')unless($img && $nam && $alt);
$sty .= ($ptr) ? ' cursor: pointer' : '';
$sty = fep_(0, Trim($sty));
my $ret = "<INPUT type='image' name='$nam' src='$img' alt='$alt'$sty>";
return($ret);
}
sub InpSelect{
my ($typ, $nam, $siz, $ptr, $sty, @dat) = @_;
return('')unless($nam);
my @ret;
$typ = ($typ) ? ' multiple' : '';
$siz = ($siz ne '') ? " size='$siz'" : '';
$sty .= ($ptr) ? ' cursor: pointer' : '';
$sty = fep_(0, $sty);
push(@ret, "<SELECT name='$nam'$siz$typ$sty>");
for(my $i = 0; $i < @dat; $i++){
my $sel = ($dat[$i][2]) ? ' selected' : '';
push(@ret, "<OPTION value='$dat[$i][0]'$sel>$dat[$i][1]</OPTION>");
}
push(@ret, '</SELECT>');
return(@ret);
}
1;