3cd26ea69597bd2306e8923c57b7fbb34db43aaa
[freeside.git] / torrus / perllib / Torrus / Renderer / Freeside.pm
1 package Torrus::Renderer::Freeside;
2
3 use strict;
4
5 #Freeside
6 use FS::Mason qw( mason_interps );
7 use FS::UID qw(cgisuidsetup);
8 use FS::TicketSystem;
9
10 my $outbuf;
11 my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
12
13 sub freesideHeader {
14   my($self, $title, $stylesheet) = @_;
15
16   #from html-incblocks.txt
17   my $head =
18   #  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
19   #  [% IF expires %]<META HTTP-EQUIV="Refresh" CONTENT="[% expires %]"/>[% END %]
20     '<STYLE type="text/css" media="all">
21      @import url( '. $Torrus::Renderer::plainURL. $stylesheet. ' );
22      </STYLE>
23     ';
24
25   $self->freesideComponent('/elements/header.html',
26                              {
27                                'title' => $title,
28                                'head'  => $head,
29                                #'etc'   => $etc,
30                                'nobr'  => 1,
31                                #'nocss' => 1,
32                              }
33                           );
34 }
35
36 sub freesideFooter {
37   my $self = shift;
38   $self->FreesideComponent('/elements/footer.html');
39 }
40
41 our $FSURL;
42
43 sub freesideComponent {
44   my($self, $comp) = (shift, shift);
45
46 #  my $conf = new FS::Conf;
47   $FS::Mason::Request::FSURL = $FSURL;
48   $FS::Mason::Request::FSURL .= '/' unless $FS::Mason::Request::FSURL =~ /\/$/;
49 #  $FS::Mason::Request::QUERY_STRING = $packet->{'query_string'} || '';
50
51   cgisuidsetup($Torrus::CGI::q);
52   FS::TicketSystem->init();
53
54   $outbuf = '';
55   #$fs_interp->exec($comp, @args); #only FS for now alas...
56   $fs_interp->exec($comp, @_); #only FS for now alas...
57
58   #errors? (turn off in-line error reporting?)
59
60   return $outbuf;
61
62 }
63
64 1;
65