{******************************************} { } { FastReport VCL } { Server templates support } { } { Copyright (c) 1998-2021 } { by Fast Reports Inc. } { } {******************************************} unit frxServerTemplates; {$I frx.inc} interface uses Classes, SysUtils, frxServerVariables, frxServerSSI, frxServerUtils, frxServerConfig; type TfrxServerTemplate = class(TObject) private FVariables: TfrxServerVariables; FSSI: TfrxSSIStream; FTemplate: TStringList; public constructor Create; destructor Destroy; override; procedure Clear; procedure Prepare; procedure SetTemplate(const Name: String); property TemplateStrings: TStringList read FTemplate; property Variables: TfrxServerVariables read FVariables; end; implementation const error403 = 'Forbidden

ERROR 403
Forbidden

'; error404 = 'Not found

ERROR 404
Not found

'; error500 = 'Internal error

ERROR 500
Internal error

'; list_begin = ''; list_header = ''; list_line = ''; list_end = '
" target=_blank>
'; form_begin = '' + '' + '' + '<!--#echo var="TITLE"-->' + '>' + '' + '' + '' + '
' + '
' + '">' + '' + '' + '">' + '" align="center" style="border: solid 1px #000000">' + ''; form_end = '
">
"> 
'; form_checkbox = '" value="" >' + '; font-size: px;' + 'color: ; background-color: ;">'; form_label = '; font-size: px; color: ; background-color: ;">'; form_memo = ''; form_text = '" name="" value="" id="" size="" maxlength="" >'; form_radio = '" value="" >' + '; font-size: px; color: ; background-color: ;">'; form_button = '" value="">'; form_select = '" name="" value="" id="" size="" maxlength="" >'; form_image = '" width="" height="">'; main = '' + '' + '<!--#echo var="TITLE"-->' + '' + '' + '' + '" noresize scrolling="no">' + '">' + '' + ''; navigator = ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + '
'#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + ''#13#10 + '
   
'; outline = ''; report = ''; print = '' + 'Print dialog' + '
' + '">">' + '' + '' + '' + '' + '' + '' + '
Print
 
 ' + '

Printer name  

' + '

Pages (enter page numbers and/or page ranges, example: 1,3,5-7)  ' + '

' + '

Number of copies  

' + '

Collate pages  

' + '

Reverse order  

 
 

      ' + '
 
'; nav_print = ' '#13#10 + ''; { TfrxServerTemplate } procedure TfrxServerTemplate.Clear; begin FVariables.Clear; FSSI.Clear; FTemplate.Clear; end; constructor TfrxServerTemplate.Create; begin FVariables := TfrxServerVariables.Create; FSSI := TfrxSSIStream.Create; FSSI.Variables := FVariables; FTemplate := TStringList.Create; end; destructor TfrxServerTemplate.Destroy; begin FSSI.Free; FVariables.Free; FTemplate.Free; inherited; end; procedure TfrxServerTemplate.Prepare; begin FSSI.Clear; FTemplate.SaveToStream(FSSI{$IFDEF Delphi12}, TEncoding.UTF8{$ENDIF}); FSSI.Prepare; FTemplate.Clear; FSSI.Position := 0; FTemplate.LoadFromStream(FSSI{$IFDEF DElphi12}, TEncoding.UTF8{$ENDIF}); end; procedure TfrxServerTemplate.SetTemplate(const Name: String); var path: String; begin path := frxGetAbsPathDir(ServerConfig.GetValue('server.http.templatespath'), ServerConfig.ConfigFolder) + name + '.html'; if FileExists(path) then FTemplate.LoadFromFile(path{$IFDEF Delphi12}, TEncoding.UTF8 {$ENDIF}) else if name = 'error403' then FTemplate.Text := error403 else if name = 'error404' then FTemplate.Text := error404 else if name = 'error500' then FTemplate.Text := error500 else if name = 'list_begin' then FTemplate.Text := list_begin else if name = 'list_header' then FTemplate.Text := list_header else if name = 'list_line' then FTemplate.Text := list_line else if name = 'list_end' then FTemplate.Text := list_end else if name = 'form_begin' then FTemplate.Text := form_begin else if name = 'form_button' then FTemplate.Text := form_button else if name = 'form_checkbox' then FTemplate.Text := form_checkbox else if name = 'form_end' then FTemplate.Text := form_end else if name = 'form_label' then FTemplate.Text := form_label else if name = 'form_memo' then FTemplate.Text := form_memo else if name = 'form_radio' then FTemplate.Text := form_radio else if name = 'form_select' then FTemplate.Text := form_select else if name = 'form_text' then FTemplate.Text := form_text else if name = 'form_date' then FTemplate.Text := form_date else if name = 'form_image' then FTemplate.Text := form_image else if name = 'main' then FTemplate.Text := main else if name = 'navigator' then FTemplate.Text := navigator else if name = 'nav_print' then FTemplate.Text := nav_print else if name = 'outline' then FTemplate.Text := outline else if name = 'report' then FTemplate.Text := report else if name = 'print' then FTemplate.Text := print; end; end.