CGI-Screen

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

      use CGI::Screen;
      use vars qw(@ISA);
      @ISA = qw(CGI::Screen);
      
      my $query = __PACKAGE__->new;
      
      $query->dispatch;
      
      sub main_screen {
        my $query = shift;
      
        print $query->p('This is the Main Screen');
      }

    That is not too exciting. Let us add a second screen and allow
    navigation between the screens:

      sub main_screen {
        my $query = shift;
      
        print
          $query->p('This is the Main Screen'),
          $query->goto_screen('second', 'Another Screen');
      }
      sub second_screen {
        my $query = shift;
      
        print
          $query->p('This is the Other Screen'),
          $query->goto_screen('main', 'Back to Main Screen');

      }

  Moving between screens

    Use the method `goto_screen' to produce a button for switching to
    another screen. You can also produce an anchor instead of a button by
    calling `link_to_screen' instead of `goto_screen'. You may pass
    additional parameters to encode:

        for my $docid (keys %score) {
          print $query->link_to_screen('display', $title{$docid},
                                       'docid' => $docid,
                                       'score' => $score{$docid});
        }

    For convenience, CGI::Screen keeps track of the last screen for you so
    that you can link to the previous page. Note that only the last seven
    screens are saved:

      my $screen = $query->last_screen;
      print
        $query->p("You came from screen $screen. Press "),
        $query->goto_screen($query->last_screen),
        $query->p(" to go back");

    `last_screen' returns screen name and title in list context and screen
    name in scalar context. Do not use the CGI parameters `screen_last_*'
    since they are changed before you can get hold of them `;-P'

  The callbacks

    All callbacks are called with three arguments: The query object, the
    screen name and the screen title (= button/anchor text). Callbacks
    should return a string.

    `application'
    The `application' method returns a string which is used in the default
    `title' and `headline' callbacks. The Default method returns the string
    `"CGI::Screen Test"' and should definitely be overwritten by your
    application.

    `title'
    The result of the method is used in the HTTP header and in the default
    headline. It defaults to the *application*.

    `headline'
    The `headline' method should return a chunk of HTML code to start the
    Screen. It defaults to the *title* enclosed in `H1' tags.

  Authentication

    To enable password authentication, define a method `check_auth_user'.
    The dispatcher will call the method with the user and password entered
    by the user. The method should return true if the authentication
    succeeded and false otherwise. The dispatcher will present the
    `login_screen' if the authentication failed.

      sub check_auth_user {
        my ($query, $user, $passwd) = @_;

        $user eq 'pfeifer';
      }

    For IP address based authentication define the method `check_auth_ip'.

      sub check_auth_ip {
        my ($query, $ipaddr) = @_;

       $ipaddr =~ /^(193\.96\.65\.|139\.4\.36\.)/;
      }

    If you do not like the default login screen, overwrite with your own
    `login_screen'. Use the CGI parameters `screen_user' and
    `screen_passwd'.

  Customizing the Title

    You may provide a custom `title' method to generate a title for your
    screens.

      sub title {
        my ($query, $screen)  = shift;
      
        $query->application . ': ' . $screen;
      }

  Customizing the Headline

    You may provide a custom `headline' method to generate a HTML chunk to
    start your screens.

      sub headline { $_[0]->h1(title(@_)) }

    You should overwrite the `application' method if you use the default
    title and headline.

      sub application { 'CGI::Screen Test' }



( run in 0.914 second using v1.01-cache-2.11-cpan-39bf76dae61 )