annotate Lib/DOM/Providers/Form.pm @ 16:75d55f4ee263

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