CGI-WML

 view release on metacpan or  search on metacpan

WML.pm  view on Meta::CPAN

        'forua="true"'      => '87',         # 0x57
        'src="http://'      => '88',         # 0x58
        'src="https://'     => '89',         # 0x59
        'http-equiv'        => '90',         # 0x5A
        'http-equiv="Content-Type"' => '91',                   # 0x5B
        'content="application/vnd.wap.wmlc;charset=' => '92',  # 0x5C
        'http-equiv="Expires"' => '93',                        # 0x5D
        'accesskey'         => '94',                           # 0x5E 
        'enctype'           => '95',                           # 0x5F
        'enctype="application/x-www-from-urlencoded"' => '96', # 0x60
        'enctype="multipart/form-data"'               => '97', # 0x61
      );

%WBML_VALUES = (      # dec              # hex
        '.com/'     => '133',            # 0x85 
        '.edu/'     => '134',            # 0x86
        '.net/'     => '135',            # 0x87 
        '.org/'     => '136',            # 0x88
        'accept'    => '137',            # 0x89
        'bottom'    => '138',            # 0x8A
        'clear'     => '139',            # 0x8B
        'delete'    => '140',            # 0x8C
        'help'      => '141',            # 0x8D
        'http://'   => '142',            # 0x8E
        'http://www.'  => '143',         # 0x8F
        'https://'     => '144',         # 0x90
        'https://www.' => '145',         # 0x91
        'NULL'      => '146',            # 0x92
        'middle'    => '147',            # 0x93
        'nowrap'    => '148',            # 0x94
        'onpick'    => '149',            # 0x95
        'onenterbackward' => '150',      # 0x96
        'onenterforward'  => '151',      # 0x97
        'ontimer'   => '152',            # 0x98
        'options'   => '153',            # 0x99
        'password'  => '154',            # 0x9A
        'reset'     => '155',            # 0x9B
        'NULL'      => '156',            # 0x9C
        'text'      => '157',            # 0x9D
        'top'       => '158',            # 0x9E
        'unknown'   => '159',            # 0x9F
        'wrap'      => '160',            # 0xA0
        'www.'      => '161');           # 0xA1

%WBML_NO_CLOSE_TAGS = (              
        'br'     => '1',                 
        'go'     => '1',                 
        'input'  => '1',                 
        'noop'   => '1',                 
        'prev'   => '1',                 
        'img'    => '1',                 
        'meta'   => '1',                 
        'timer'  => '1',                 
        'setvar' => '1');

# HTML->WML conversion constants
# Ignore these HTML and iMode tags completely.
my %IGNORE_TAG = map {$_ => 1} qw(abbr acronym address applet area basefont
				  bdo body cite col colgroup del dfn dir div
				  dl dt fieldsset font frame frameset head
				  html iframe legend link noframes noscript 
				  object param script span style textarea
				  tfoot thead var);

# Straightforward one to one tag mapping
my %TAGMAP = map {$_ => 1} qw(em strong i b u big small pre tr td); 

my (%Open_Tags,@Open_Tables,$Open_Form_Url,
    @Open_Vars,%Hidden_Vars,$F_Got_Body_Tag);

### 
##  End of global variable setting. 
###

### Method: header
# Override the CGI.pm header default with the WML one.
# Contributed by Wilbert Smits <wilbert@telegraafnet.nl>
###
sub header {
    local($^W)=0;
    my($self,@p) = &CGI::self_or_default(@_);
    my($type, @leftover) = rearrange([TYPE],@p);
    my %leftover;
    foreach (@leftover) {
        next unless my($header,$value) = /([^\s=]+)=\"?([^\"]+)\"?/;
        $leftover{$header} = $value;
    }
    if(!defined $type) {$type = "text/vnd.wap.wml"}
    return $self->SUPER::header("-type"=>$type, %leftover);
}

### Method: start_wml
# Guess what this does!
###
sub start_wml {
    my($self,@p) = &CGI::self_or_default(@_);
    my($meta,$dtd,$dtd_url,$lang,$encoding) =
	rearrange([META,DTD,DTD_URL,LANG,ENCODING],@p);
    
    if (!defined $encoding) { $encoding="iso-8859-1";}
    
    my(@result);
    push @result,qq(<?xml version="1.0" encoding="$encoding"?>);
    $dtd = $DEFAULT_DTD unless $dtd && $dtd =~ m|^-//|;
    $dtd_url = $DEFAULT_DTD_URL unless $dtd_url && $dtd_url =~ m|^http|;
    push(@result,qq(\n<!DOCTYPE wml PUBLIC "$dtd" 
	            "$dtd_url">\n)) if $dtd && $dtd_url;

    push(@result,qq(<wml));
    push(@result,qq(xml:lang="$lang")) if (defined $lang);
    push(@result,">");

    if (defined $meta) {
        push(@result,"<head>");
        if ($meta && ref($meta) && (ref($meta) eq 'HASH')) {
            foreach (keys %$meta) {
                push(@result,qq(<meta $_ $meta->{$_}/>\n));
            }
        }
        push(@result,"</head>");
    }



( run in 1.550 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )