| 1 | |||
| 2 | ################################################################################### | ||
| 3 | # | ||
| 4 | # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de | ||
| 5 | # Embperl - Copyright (c) 2008-2015 Gerald Richter | ||
| 6 | # Embperl - Copyright (c) 2015-2023 actevy.io | ||
| 7 | # | ||
| 8 | # You may distribute under the terms of either the GNU General Public | ||
| 9 | # License or the Artistic License, as specified in the Perl README file. | ||
| 10 | # | ||
| 11 | # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR | ||
| 12 | # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
| 13 | # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | ################################################################################### | ||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | package Embperl::Syntax::EmbperlHTML ; | ||
| 20 | |||
| 21 | use Embperl::Syntax qw{:types} ; | ||
| 22 | use Embperl::Syntax::HTML ; | ||
| 23 | |||
| 24 | use strict ; | ||
| 25 | use vars qw{@ISA} ; | ||
| 26 | |||
| 27 | @ISA = qw(Embperl::Syntax::HTML) ; | ||
| 28 | |||
| 29 | |||
| 30 | ################################################################################### | ||
| 31 | # | ||
| 32 | # Methods | ||
| 33 | # | ||
| 34 | ################################################################################### | ||
| 35 | |||
| 36 | # --------------------------------------------------------------------------------- | ||
| 37 | # | ||
| 38 | # Create new Syntax Object | ||
| 39 | # | ||
| 40 | # --------------------------------------------------------------------------------- | ||
| 41 | |||
| 42 | sub new | ||
| 43 | |||
| 44 | { | ||
| 45 | my $class = shift ; | ||
| 46 | |||
| 47 | my $self = Embperl::Syntax::HTML::new ($class) ; | ||
| 48 | |||
| 49 | Init ($self) ; | ||
| 50 | |||
| 51 | return $self ; | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | ################################################################################### | ||
| 57 | # | ||
| 58 | # Definitions for Embperl HTML tags | ||
| 59 | # | ||
| 60 | ################################################################################### | ||
| 61 | |||
| 62 | sub Init | ||
| 63 | |||
| 64 | { | ||
| 65 | my ($self) = @_ ; | ||
| 66 | |||
| 67 | $self -> AddInitCode ('use vars qw{$_ep_selectname};') ; | ||
| 68 | |||
| 69 | $self -> AddTag ('input', ['type', 'name', 'value'], ['src'], ['checked'], | ||
| 70 | { | ||
| 71 | perlcode => | ||
| 72 | [ | ||
| 73 | 'Embperl::Cmd::InputCheck (%$n%, %&*\'name%, %&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ', | ||
| 74 | '$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%, \'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ; %&!-value%', | ||
| 75 | '$idat{%&*\'name%}=%&*\'value% ; ', | ||
| 76 | ] | ||
| 77 | }) ; | ||
| 78 | $self -> AddTagBlock ('textarea', ['name'], undef, undef, | ||
| 79 | { | ||
| 80 | perlcode => | ||
| 81 | [ | ||
| 82 | '$idat{%&*\'name%}=$fdat{%&*\'name%};_ep_ac(%$n%, Embperl::Syntax::ntypText + 0x20, $fdat{%&*\'name%}) ; %#!-0%', | ||
| 83 | '$idat{%&*\'name%}=%#*\'0% ; ', | ||
| 84 | ] | ||
| 85 | }) ; | ||
| 86 | |||
| 87 | $self -> AddTagBlock ('tr', undef, undef, undef, | ||
| 88 | { | ||
| 89 | perlcode => 'l%$p%: for (my $col = 0; $col < $maxcol; $col++) {' , | ||
| 90 | perlcodeend => '} %?*-htmlrow%' , | ||
| 91 | perlcoderemove => 1, | ||
| 92 | stackname => 'htmlrow', | ||
| 93 | 'push' => '%$p%', | ||
| 94 | mayjump => 1, | ||
| 95 | }) ; | ||
| 96 | |||
| 97 | my %ProcInfoTable = ( | ||
| 98 | perlcode => 'l%$p%: for (my $row = 0; $row < $maxrow; $row++) {' , | ||
| 99 | perlcodeend => '} %?*-htmltable%' , | ||
| 100 | perlcoderemove => 1, | ||
| 101 | stackname => 'htmltable', | ||
| 102 | 'push' => '%$p%', | ||
| 103 | mayjump => 1, | ||
| 104 | ) ; | ||
| 105 | |||
| 106 | $self -> AddTagBlock ('table', undef, undef, undef, \%ProcInfoTable) ; | ||
| 107 | $self -> AddTagBlock ('ol', undef, undef, undef, \%ProcInfoTable) ; | ||
| 108 | $self -> AddTagBlock ('ul', undef, undef, undef, \%ProcInfoTable) ; | ||
| 109 | $self -> AddTagBlock ('dl', undef, undef, undef, \%ProcInfoTable) ; | ||
| 110 | $self -> AddTagBlock ('menu', undef, undef, undef, \%ProcInfoTable) ; | ||
| 111 | $self -> AddTagBlock ('dir', undef, undef, undef, \%ProcInfoTable) ; | ||
| 112 | |||
| 113 | |||
| 114 | $self -> AddTagBlock ('select', ['name'], undef, undef, | ||
| 115 | { | ||
| 116 | stackname2 => 'htmlselect', | ||
| 117 | push2 => '%&*\'name%', | ||
| 118 | |||
| 119 | perlcode => 'l%$p%: for (my $row = 0; $row < $maxrow; $row++) {' , | ||
| 120 | perlcodeend => '} %?*-htmltable%' , | ||
| 121 | perlcoderemove => 1, | ||
| 122 | stackname => 'htmltable', | ||
| 123 | 'push' => '%$p%', | ||
| 124 | mayjump => 1, | ||
| 125 | }, | ||
| 126 | { | ||
| 127 | procinfo => | ||
| 128 | { | ||
| 129 | 'embperl#2' => | ||
| 130 | { | ||
| 131 | perlcode => '{ my $_ep_selectname=%&*\'name%;', | ||
| 132 | perlcodeend => '} %&*-name%', | ||
| 133 | # push/pop is not (yet) supported in secondary entry, so don't use it!! | ||
| 134 | #stackname => 'htmltable', | ||
| 135 | #'push' => '%$p%', | ||
| 136 | } | ||
| 137 | } | ||
| 138 | } | ||
| 139 | ) ; | ||
| 140 | # option tag are _not_ added as block, to allow <option> without </option> | ||
| 141 | # which are interpreted correct by most browsers | ||
| 142 | $self -> AddTag ('option', ['value'], undef, ['selected'], | ||
| 143 | { | ||
| 144 | perlcode => | ||
| 145 | [ | ||
| 146 | '_ep_opt (%$n%, $_ep_selectname, %&*\'value%, %&\'selected%);', | ||
| 147 | '_ep_opt (%$n%, $_ep_selectname, %>*\'1%, %&\'selected%);', | ||
| 148 | #'_ep_opt (%$n%, %^*htmlselect%, %&*\'value%, %&\'selected%);', | ||
| 149 | #'_ep_opt (%$n%, %^*htmlselect%, %>*\'1%, %&\'selected%);', | ||
| 150 | ] | ||
| 151 | }, | ||
| 152 | { 'nodename' => ':<:>:option:', 'cdatatype' => ntypAttrValue, procinfo => {} }) ; | ||
| 153 | |||
| 154 | $self -> AddTagWithStart ('/option', 'option', undef, undef, undef, undef, | ||
| 155 | { 'nodename' => ':</:>:option:', 'cdatatype' => ntypAttrValue, procinfo => {} } ) ; | ||
| 156 | |||
| 157 | $self -> AddTag ('a', undef, ['href'], undef, undef, { 'nodename' => ':<:>:a:', 'cdatatype' => ntypAttrValue, procinfo => {} }, 1) ; | ||
| 158 | $self -> AddTag ('area', undef, ['href'], undef, undef, undef, 1) ; | ||
| 159 | $self -> AddTag ('frame', undef, ['src'], undef, undef, undef, 1) ; | ||
| 160 | $self -> AddTag ('iframe', undef, ['src'], undef, undef, undef, 1) ; | ||
| 161 | $self -> AddTag ('embed', undef, ['src'], undef, undef) ; | ||
| 162 | $self -> AddTag ('layer', undef, ['src'], undef, undef) ; | ||
| 163 | $self -> AddTag ('img', undef, ['src'], undef, undef) ; | ||
| 164 | $self -> AddTag ('form', undef, ['action'], undef, undef, { 'nodename' => ':<:>:form:', 'cdatatype' => ntypAttrValue, procinfo => {} }, 2) ; | ||
| 165 | |||
| 166 | } | ||
| 167 | |||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | 1; | ||
| 174 | |||
| 175 | |||
| 176 | |||
| 177 | __END__ |