飛鳥 真一郎 > CGI-Application-Plugin-Eparam-0.04f > CGI::Application::Plugin::Eparam

Download:
CGI-Application-Plugin-Eparam-0.04f.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  

Name ^

CGI::Application::Plugin::Eparam

SYNOPSIS ^

    package WebApp
    use Jcode;# or use Encode or $CGI::Application::Plugin::Eparam::econv = sub { ... }
    use CGI::Application::Plugin::Eparam;
    sub cgiapp_init {
            $CGI::Application::Plugin::Eparam::icode = 'sjis';   # input code
            $CGI::Application::Plugin::Eparam::ocode = 'euc-jp'; # want  code
    }
    package WebApp::Pages::Public
    sub page1 {
            my $self = shift;
            my $data = $self->eparam('data');               # convert data
            my $natural_data = $self->query->param('data'); # data
    }

Example ^

Get Value

    package WebApp::Pages::Public
    sub page1 {
            my $self = shift;
            my $data = $self->eparam('data');               # convert data
            my $natural_data = $self->query->param('data'); # data
    }

in Application

    package WebApp
    use Jcode;# or use Encode or $CGI::Application::Plugin::Eparam::econv = sub { ... }
    use CGI::Application::Plugin::Eparam;
    sub cgiapp_init {
            $CGI::Application::Plugin::Eparam::icode = 'sjis';   # input code
            $CGI::Application::Plugin::Eparam::ocode = 'euc-jp'; # want  code
    }

in SubClass

    package WebApp::Pages::Public
    sub setup {
            $CGI::Application::Plugin::Eparam::icode = 'sjis';
            $CGI::Application::Plugin::Eparam::ocode = 'euc-jp';
    }
    package WebApp::Pages::Admin
    sub setup {
            $CGI::Application::Plugin::Eparam::icode = 'euc-jp';
            $CGI::Application::Plugin::Eparam::ocode = 'euc-jp';
    }

in Method

    package WebApp::Pages::User::Mailform
    sub mailform {

            # this case is no convert
            $CGI::Application::Plugin::Eparam::icode = 'jis';
            $CGI::Application::Plugin::Eparam::ocode = 'jis';

            # The thing used for the character-code conversion before Mail Sending can be done. 
            $CGI::Application::Plugin::Eparam::icode = 'sjis';
            $CGI::Application::Plugin::Eparam::ocode = 'jis';

    }

in Part

    package Myapplication::Pages::User::Mailform
    sub mailform {

            # temp_ocode are given to priority more than ocode.
            $CGI::Application::Plugin::Eparam::temp_icode = 'sjis';
            $CGI::Application::Plugin::Eparam::temp_ocode = 'jis';
            my $val_jis = $self->eparam('val');
            # It returns it.
            undef $CGI::Application::Plugin::Eparam::temp_icode;
            undef $CGI::Application::Plugin::Eparam::temp_ocode;
            my $val_sjis = $self->eparam('val');

    }

Convert Logic Customize

    # It is very effective.
    $CGI::Application::Plugin::Eparam::econv = sub {
            my $textref = shift; 
            my $ocode = shift;   # output character code
            my $icode = shift;   # input  character code
            # some logic
            Encode::from_to($$textref, 'Guess', $ocode);
    };
    # It is temporarily effective.
    $CGI::Application::Plugin::Eparam::temp_econv = sub {
            my $textref = shift; 
            my $ocode = shift;   # output character code
            my $icode = shift;   # input  character code
            # some logic
            Encode::from_to($$textref, 'Guess', $ocode);
    };
    # It returns to the processing of the standard.
    undef $CGI::Application::Plugin::Eparam::temp_econv;

SEE ALSO ^

CGI::Application

AUTHOR ^

Shinichiro Aska

syntax highlighting: