4 use vars qw(@EXPORT_OK @ISA);
8 use CGI::Carp qw(fatalsToBrowser);
12 @EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable);
16 FS::CGI - Subroutines for the web interface
20 use FS::CGI qw(header menubar idiot eidiot popurl);
22 print header( 'Title', '' );
23 print header( 'Title', menubar('item', 'URL', ... ) );
25 idiot "error message";
26 eidiot "error message";
28 $url = popurl; #returns current url
29 $url = popurl(3); #three levels up
33 Provides a few common subroutines for the web interface.
39 =item header TITLE, MENUBAR
41 Returns an HTML header.
46 my($title,$menubar,$etc)=@_; #$etc is for things like onLoad= etc.
48 $etc = '' unless defined $etc;
57 <BODY BGCOLOR="#e8e8e8"$etc>
63 $x .= $menubar. "<BR><BR>" if $menubar;
67 =item menubar ITEM, URL, ...
69 Returns an HTML menubar.
73 sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... );
76 ($item,$url)=splice(@_,0,2);
77 push @html, qq!<A HREF="$url">$item</A>!;
84 This is depriciated. Don't use it.
86 Sends headers and an HTML error message.
91 #warn "idiot depriciated";
93 my $cgi = &FS::UID::cgi();
94 if ( $cgi->isa('CGI::Base') ) {
96 &CGI::Base::SendHeaders;
98 print $cgi->header( '-expires' => 'now' );
103 <TITLE>Error processing your request</TITLE>
107 <H4>Error processing your request</H4>
109 Your request could not be processed because of the following error:
119 This is depriciated. Don't use it.
121 Sends headers and an HTML error message, then exits.
126 warn "eidiot depriciated";
128 if (exists $ENV{MOD_PERL}) {
129 $main::Response->End()
130 if defined $main::Response
131 && $main::Response->isa('Apache::ASP::Response');
141 Returns current URL with LEVEL levels of path removed from the end (default 0).
147 my $cgi = &FS::UID::cgi;
148 my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url );
149 my(@path)=$url->path_components;
151 $url->path_components(@path);
152 my $x = $url->as_string;
153 $x .= '/' unless $x =~ /\/$/;
159 Returns HTML tag for beginning a table.
166 qq!<TABLE BGCOLOR="$col" BORDER=1 WIDTH="100%">!;
174 Returns HTML tag for beginning an (invisible) table.
180 my $cellspacing = shift || 0;
182 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
184 qq!<TABLE BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
190 This is getting silly.
196 my $cellspacing = shift || 0;
198 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;