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)=@_;
55 <BODY BGCOLOR="#e8e8e8">
61 $x .= $menubar. "<BR><BR>" if $menubar;
65 =item menubar ITEM, URL, ...
67 Returns an HTML menubar.
71 sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... );
74 ($item,$url)=splice(@_,0,2);
75 push @html, qq!<A HREF="$url">$item</A>!;
82 This is depriciated. Don't use it.
84 Sends headers and an HTML error message.
89 #warn "idiot depriciated";
91 my $cgi = &FS::UID::cgi();
92 if ( $cgi->isa('CGI::Base') ) {
94 &CGI::Base::SendHeaders;
96 print $cgi->header( '-expires' => 'now' );
101 <TITLE>Error processing your request</TITLE>
105 <H4>Error processing your request</H4>
107 Your request could not be processed because of the following error:
117 This is depriciated. Don't use it.
119 Sends headers and an HTML error message, then exits.
124 #warn "eidiot depriciated";
126 if (exists $ENV{MOD_PERL}) {
138 Returns current URL with LEVEL levels of path removed from the end (default 0).
144 my $cgi = &FS::UID::cgi;
145 my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url );
146 my(@path)=$url->path_components;
148 $url->path_components(@path);
149 my $x = $url->as_string;
150 $x .= '/' unless $x =~ /\/$/;
156 Returns HTML tag for beginning a table.
163 qq!<TABLE BGCOLOR="$col" BORDER=1 WIDTH="100%">!;
171 Returns HTML tag for beginning an (invisible) table.
177 my $cellspacing = shift || 0;
179 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
181 qq!<TABLE BORDER=0 CELLSPACING=$cellspacing WIDTH="100%">!;
187 This is getting silly.
193 my $cellspacing = shift || 0;
195 qq!<TABLE BGCOLOR="$col" BORDER=0 CELLSPACING=$cellspacing>!;