comparison Lib/DOM/Providers/Form.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 16ada169ca75
comparison
equal deleted inserted replaced
-1:000000000000 0:03e58a454b20
1 package Configuration;
2 our $DataDir;
3 package DOM::Providers::Form;
4 use strict;
5 use Form;
6 use Schema::Form;
7 use Common;
8 our @ISA = qw(Object);
9
10 our $Encoding ;
11 our $CacheDir ||= "${DataDir}Cache/";
12 warn "The encoding for the DOM::Provider::Form isn't specified" if not $Encoding;
13 $Encoding ||= 'utf-8';
14
15 sub GetProviderInfo {
16 return {
17 Name => 'Form',
18 Host => 'DOM::Site',
19 Methods => {
20 LoadForm => \&SiteLoadForm
21 }
22 }
23 }
24
25 BEGIN {
26 DeclareProperty FormsEncoding => ACCESS_READ;
27 DeclareProperty DataCacheDir => ACCESS_READ;
28 }
29
30 sub SiteLoadForm {
31 my ($this,$site,$file,$form) = @_;
32 return $site->RegisterObject('Form',$this->LoadForm($file,$form));
33 }
34
35 sub LoadForm {
36 my ($this,$file, $formName) = @_;
37
38 my $formSchema = Schema::Form->LoadForms($file,$this->{$DataCacheDir},$this->{$FormsEncoding})->{$formName} or die new Exception('The form isn\'t found',$formName,$file);
39 return Form->new($formSchema);
40 }
41
42 sub construct {
43 my ($class) = @_;
44
45 return $class->new(FormsEncoding => $Encoding, DataCacheDir => $CacheDir);
46 }
47
48
49 1;