summaryrefslogtreecommitdiff
path: root/torrus/perllib/Torrus/Freeside.pm
blob: 1b0a2812258067326e5f2a1a693567beae2564e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package Torrus::Freeside;

use strict;
use warnings;

#Freeside
use FS::Mason qw( mason_interps );
use FS::UID qw(cgisuidsetup);
use FS::TicketSystem;

my $outbuf;
my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);

sub freesideHeader {
  my($self, $title, $stylesheet) = @_;

  #from html-incblocks.txt
  my $head =
  #  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
  #  [% IF expires %]<META HTTP-EQUIV="Refresh" CONTENT="[% expires %]"/>[% END %]
    '<STYLE type="text/css" media="all">
     @import url( '. $Torrus::Renderer::plainURL. $stylesheet. ' );
     </STYLE>
    ';

  $self->freesideComponent('/elements/header.html',
                             {
                               'title' => $title,
                               'head'  => $head,
                               #'etc'   => $etc,
                               #'nobr'  => 1,
                               #'nocss' => 1,
                             }
                          );
}

sub freesideFooter {
  my $self = shift;
  $self->freesideComponent('/elements/footer.html');
}

our $FSURL;

sub freesideComponent {
  my($self, $comp) = (shift, shift);

#  my $conf = new FS::Conf;
  $FS::Mason::Request::FSURL = $FSURL;
  $FS::Mason::Request::FSURL .= '/' unless $FS::Mason::Request::FSURL =~ /\/$/;
#  $FS::Mason::Request::QUERY_STRING = $packet->{'query_string'} || '';

  cgisuidsetup($Torrus::CGI::q);
  FS::TicketSystem->init();

  $outbuf = '';
  #$fs_interp->exec($comp, @args); #only FS for now alas...
  $fs_interp->exec($comp, @_); #only FS for now alas...

  #errors? (turn off in-line error reporting?)

  return $outbuf;

}

1;