4 use vars qw(@EXPORT_OK @ISA @header);
8 use CGI::Carp qw(fatalsToBrowser);
12 @EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable);
14 @header = ( '-Expires' => '-1',
15 '-Pragma' => 'no-cache',
16 '-Cache-Control' => 'no-cache' );
20 FS::CGI - Subroutines for the web interface
24 use FS::CGI qw(header menubar idiot eidiot popurl);
26 print header( 'Title', '' );
27 print header( 'Title', menubar('item', 'URL', ... ) );
29 idiot "error message";
30 eidiot "error message";
32 $url = popurl; #returns current url
33 $url = popurl(3); #three levels up
37 Provides a few common subroutines for the web interface.
43 =item header TITLE, MENUBAR
45 Returns an HTML header.
50 my($title,$menubar,$etc)=@_; #$etc is for things like onLoad= etc.
52 $etc = '' unless defined $etc;
61 <BODY BGCOLOR="#e8e8e8"$etc>
67 $x .= $menubar. "<BR><BR>" if $menubar;
71 =item menubar ITEM, URL, ...
73 Returns an HTML menubar.
77 sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... );
80 ($item,$url)=splice(@_,0,2);
81 push @html, qq!<A HREF="$url">$item</A>!;
88 This is depriciated. Don't use it.
90 Sends headers and an HTML error message.
95 #warn "idiot depriciated";
97 my $cgi = &FS::UID::cgi();
98 # if ( $cgi->isa('CGI::Base') ) {
100 # &CGI::Base::SendHeaders;
102 print $cgi->header( @FS::CGI::header );
107 <TITLE>Error processing your request</TITLE>
111 <H4>Error processing your request</H4>
113 Your request could not be processed because of the following error:
123 This is depriciated. Don't use it.
125 Sends headers and an HTML error message, then exits.
130 warn "eidiot depriciated";
132 if (exists $ENV{MOD_PERL}) {
133 $main::Response->End()
134 if defined $main::Response
135 && $main::Response->isa('Apache::ASP::Response');
145 Returns current URL with LEVEL levels of path removed from the end (default 0).
151 my $cgi = &FS::UID::cgi;
152 my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url );
153 my(@path)=$url->path_components;
155 $url->path_components(@path);
156 my $x = $url->as_string;
157 $x .= '/' unless $x =~ /\/$/;
163 Returns HTML tag for beginning a table.
170 qq!<TABLE BGCOLOR="$col" BORDER=1 WIDTH="100%">!;
178 Returns HTML tag for beginning an (invisible) table.
184 my $cellspacing = shift || 0;
186 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
188 qq!<TABLE BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
194 This is getting silly.
200 my $cellspacing = shift || 0;
202 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;