钱宇/Qian Yu > EasyCGI-2.0.4 > EasyCGI

Download:
EasyCGI-2.0.4.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 2.0.4   Source  

NAME ^

EasyCGI - Perl CGI Interface

SYNOPSIS ^

  use EasyCGI;
  
  if(defined(&EasyCGI::foo)){
    print "lib is included";
  }else{
    print "lib is not included";
  }
  
        my $view=EasyCGI->new({
                        access => undef,                                # set true if u have own cgi interface
                        cgi_path => undef,                      # position of your own cgi interface
                        dba_path => undef,                      # position of database interface
                        cgi => undef,                                           # cgi handler
                        dba => undef,                                           # database handler
                        language => 'utf8',             # language: un cn jp utf8, default is utf8
                        src_encoding => undef,  # source code(.cgi) encoding, default is utf-8
                        web_encoding => undef,  # web page encoding, default is utf-8
                        template_file_base_path => undef,       # if null, use absolute file path
                        disable_cookie => 1                     # disable for not support cookie, default is ''
        });
        
        ############### TXT ################
        # $view->set_return_type('txt');
        #
        # my $content='remote_addr: '.$view->remote_addr()."\n";
        #
        # $view->set_content($content);
        ####################################
        
        ############### HTML ################
        # $view->set_return_type('html');
        #
        # my $content='<p>remote_addr: '.$view->remote_addr().'</p>';
        #
        # $view->set_content($content);
        #####################################
        
        ############### REDIRECT ################
        # $view->set_return_type('redirect');
        #
        # my $url='test.html';
        #
        # $view->set_url($url);
        #########################################
        
        ############### FILE ################
        # $view->set_return_type('file');
        #
        # my $file='test.txt';
        #
        # $view->set_file($file);
        #####################################
        
        print $view->output();

The synopsis above only lists the major methods and parameters.

Basic Function ^

foo - check whether this module is be used

  if(defined(&EasyCGI::foo)){
    print "lib is included";
  }else{
    print "lib is not included";
  }

new - new a instance

        my $view=EasyCGI->new($rh_option);

        $rh_option is a hash_ref has below option:
                        
                        access : set true if u have own cgi interface
                        cgi_path : position of your own cgi interface
                        dba_path : position of database access
                        cgi : cgi handler
                        dba : database access
                        language : language: un cn jp utf8, default is utf8
                        src_encoding : source code(.cgi) encoding, default is utf-8
                        web_encoding : web page encoding, default is utf-8
                        template_file_base_path : if null, use absolute file path
                        disable_cookie : disable for not support cookie, default is ''

cgi - get the cgi handler

                my $cgi = $view->cgi();

dba - get the database access

                my $dba = $view->dba();

set_dba - set the database access

                $view->set_dba($dba);

lock - cannot read param any more when locked

                $view->lock();

output - generate the page content

                $print $view->output();

query_param - read params

                #first  look up in url param
                #second look up in post param
                #third  look up in cookie param
                
                my $id = $view->query_param('id');

url_param - read url params

                my $id = $view->url_param('id');

post_param - read post params

                #first  look up in post param
                #second look up in url param
                
                my $id = $view->post_param('id');

cookie_param - read cookie params

                my $id = $view->cookie_param('id');

file - get files

                my ($file_1, $file_2, $file_3) = $view->file();
                my $file_1 = $view->file();

push_cookie - add cookie param

                $view->push_cookie($cookie);

cookie - get cookies

                $cookie = $view->cookie();

set_return_type - set the return type

                $view->set_return_type('redirect');
                $view->set_return_type('html', 'utf-8');
                
                return type can be:
                        'redirect', 'txt', 'html', 'file'
                if you set return type to 'txt' or 'html', you can have the second param for the web page encoding.

set_tmpl_type - set the template type

                $view->set_tmpl_type('ht');
                $view->set_tmpl_type('tt');
                
                template type can be:
                        'ht'(default), 'tt'

set_url - set the redirect url

                $view->set_url($url);
                
                you can set url only if the return type is 'redirect'

set_content - set page content

                $view->set_content($content);
                
                you can set content only if the return type is 'txt' or 'html', and have not set tmpl and tmpl_scalar

set_tmpl - set page template from a .tmpl file

                $view->set_tmpl($tmpl);
                
                you can set tmpl only if the return type is 'txt' or 'html', and have not set content and tmpl_scalar

set_tmpl_scalar - set page template from a string in memory

                $view->set_tmpl_scalar($tmpl);
                
                you can set tmpl_scalar only if the return type is 'txt' or 'html', and have not set content and tmpl

set_tmpl_var - set tmpl_var

                $view->set_tmpl_var($rh_tmpl_var);
                
                you can set tmpl_var only if the return type is 'txt' or 'html', and have set tmpl or tmpl_scalar

set_fill_var - set fill_var

                $view->set_fill_var($rh_fill_var);
                
                you can set fill_var only if the return type is 'txt' or 'html'

set_fill_back - set fill back varaibles

                $view->set_fill_back($ra_keys);
                
                you can set fill_back only if the return type is 'txt' or 'html'

set_file - set file

                $view->set_file($rh_file);
                
                you can set file only if the return type is 'file'

session - get sessions

                my $rh=$view->session();

session_create - create session

                $rh_session = $view->session_create($rh);

session_load - load session

                $rh_session = $view->session_load($rh);

session_save - save session

                $view->session_save($rh);

session_delete - delete session

                $view->session_delete($rh);

COPYRIGHT ^

The EasyCGI module is Copyright (c) 2003-2005 QIAN YU. All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.