X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=site_perl%2FCGI.pm;h=b21a88837b1d2c0111d698ec2f939fc9cb3d9055;hb=09a5eb8c6c43659d31fc043f556e404dcf322b13;hp=8970b301c25a4f8c68ed2d77ea3addd18401e2da;hpb=51e93bcc017e9355408ff25f232dd9183b62b196;p=freeside.git diff --git a/site_perl/CGI.pm b/site_perl/CGI.pm index 8970b301c..b21a88837 100644 --- a/site_perl/CGI.pm +++ b/site_perl/CGI.pm @@ -9,7 +9,7 @@ use CGI::Carp qw(fatalsToBrowser); use FS::UID; @ISA = qw(Exporter); -@EXPORT_OK = qw(header menubar idiot eidiot url); +@EXPORT_OK = qw(header menubar idiot eidiot popurl table); =head1 NAME @@ -17,7 +17,7 @@ FS::CGI - Subroutines for the web interface =head1 SYNOPSIS - use FS::CGI qw(header menubar idiot eidiot url); + use FS::CGI qw(header menubar idiot eidiot popurl); print header( 'Title', '' ); print header( 'Title', menubar('item', 'URL', ... ) ); @@ -25,8 +25,8 @@ FS::CGI - Subroutines for the web interface idiot "error message"; eidiot "error message"; - $url = url; #returns current url - $url = url (3); #three levels up + $url = popurl; #returns current url + $url = popurl(3); #three levels up =head1 DESCRIPTION @@ -121,20 +121,32 @@ sub eidiot { exit; } -=item url LEVEL +=item popurl LEVEL Returns current URL with LEVEL levels of path removed from the end (default 0). =cut -=item url { +sub popurl { my($up)=@_; - my($cgi)=FS::UID::cgi; - my($url)=new URI::URL $cgi; + my($cgi)=&FS::UID::cgi; + my($url)=new URI::URL $cgi->url; my(@path)=$url->path_components; - pop @path foreach ( 1.. $up ); + splice @path, 0-$up; $url->path_components(@path); - $url->as_string; + my $x = $url->as_string; + $x .= '/' unless $x =~ /\/$/; + $x; +} + +=item table + +Returns HTML tag for beginning a table. + +=cut + +sub table { + "