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)=@_;
48 #confess $etc if defined $etc;
49 $etc = '' unless defined $etc;
58 <BODY BGCOLOR="#e8e8e8"$etc>
64 $x .= $menubar. "<BR><BR>" if $menubar;
68 =item menubar ITEM, URL, ...
70 Returns an HTML menubar.
74 sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... );
77 ($item,$url)=splice(@_,0,2);
78 push @html, qq!<A HREF="$url">$item</A>!;
85 This is depriciated. Don't use it.
87 Sends headers and an HTML error message.
92 #warn "idiot depriciated";
94 my $cgi = &FS::UID::cgi();
95 if ( $cgi->isa('CGI::Base') ) {
97 &CGI::Base::SendHeaders;
99 print $cgi->header( '-expires' => 'now' );
104 <TITLE>Error processing your request</TITLE>
108 <H4>Error processing your request</H4>
110 Your request could not be processed because of the following error:
120 This is depriciated. Don't use it.
122 Sends headers and an HTML error message, then exits.
127 warn "eidiot depriciated";
129 if (exists $ENV{MOD_PERL}) {
130 $main::Response->End()
131 if defined $main::Response
132 && $main::Response->isa('Apache::ASP::Response');
142 Returns current URL with LEVEL levels of path removed from the end (default 0).
148 my $cgi = &FS::UID::cgi;
149 my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url );
150 my(@path)=$url->path_components;
152 $url->path_components(@path);
153 my $x = $url->as_string;
154 $x .= '/' unless $x =~ /\/$/;
160 Returns HTML tag for beginning a table.
167 qq!<TABLE BGCOLOR="$col" BORDER=1 WIDTH="100%">!;
175 Returns HTML tag for beginning an (invisible) table.
181 my $cellspacing = shift || 0;
183 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
185 qq!<TABLE BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
191 This is getting silly.
197 my $cellspacing = shift || 0;
199 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;