1 |
693 |
ahitrov |
package money::State; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings 'all'; |
5 |
|
|
use vars qw($AUTOLOAD); |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
sub new { |
9 |
|
|
my ($proto) = @_; |
10 |
|
|
my $class = ref($proto) || $proto; |
11 |
|
|
my $self = {}; |
12 |
|
|
bless $self, $class; |
13 |
|
|
|
14 |
|
|
# configured |
15 |
|
|
$self->{project} = '@PROJECT@'; |
16 |
|
|
$self->{debug} = (lc('@DEBUG@') eq 'yes'); |
17 |
|
|
$self->{contenido_notab} = 1; |
18 |
|
|
$self->{tab_name} = 'money'; |
19 |
|
|
$self->{project_name} = '@PROJECT_NAME@'; |
20 |
|
|
$self->{default_expire} = '@DEFAULT_EXPIRE@' || 300; |
21 |
|
|
$self->{default_object_expire} = '@DEFAULT_OBJECT_EXPIRE@' || 600; |
22 |
|
|
|
23 |
|
|
# зашитая конфигурация плагина |
24 |
|
|
$self->{db_type} = 'none'; ### For REAL database use 'remote' |
25 |
|
|
$self->{db_keepalive} = 0; |
26 |
|
|
$self->{db_host} = ''; |
27 |
|
|
$self->{db_name} = ''; |
28 |
|
|
$self->{db_user} = ''; |
29 |
|
|
$self->{db_password} = ''; |
30 |
|
|
$self->{db_port} = ''; |
31 |
|
|
$self->{store_method} = 'toast'; |
32 |
|
|
$self->{cascade} = 1; |
33 |
|
|
$self->{db_prepare} = 0; |
34 |
|
|
|
35 |
|
|
$self->{memcached_enable} = lc( '@MEMCACHED_ENABLE@' ) eq 'yes' ? 1 : 0; |
36 |
|
|
$self->{memcached_backend} = '@MEMCACHED_BACKEND@'; |
37 |
|
|
$self->{memcached_select_timeout} = '@MEMCACHED_SELECT_TIMEOUT@' || 0.2; |
38 |
|
|
$self->{memcached_servers} = [qw(@MEMCACHED_SERVERS@)]; |
39 |
|
|
$self->{memcached_enable_compress} = lc( '@MEMCACHED_ENABLE_COMPRESS@' ) eq 'yes' ? 1 : 0; |
40 |
|
|
$self->{memcached_delayed} = lc('@MEMCACHED_DELAYED@') eq 'yes' ? 1 : 0; |
41 |
|
|
$self->{memcached_set_mode} = lc('@MEMCACHED_SET_MODE@') eq 'add' ? 'add' : 'set'; |
42 |
|
|
$self->{memcached_busy_lock} = 60; |
43 |
|
|
$self->{memcached_namespace} = lc( $self->{'project'} ).'|plugin_payments|'; |
44 |
|
|
|
45 |
|
|
$self->{serialize_with} = 'json'; ### or 'dumper' |
46 |
|
|
|
47 |
|
|
# not implemented really (core compatibility) |
48 |
|
|
$self->{binary_directory} = '/nonexistent'; |
49 |
|
|
$self->{data_directory} = '/nonexistent'; |
50 |
|
|
$self->{images_directory} = '/nonexistent'; |
51 |
|
|
$self->{preview} = '0'; |
52 |
|
|
|
53 |
|
|
$self->{dreamkas_app_id} = '@DREAMKAS_ID@'; |
54 |
|
|
$self->{dreamkas_app_secret} = '@DREAMKAS_SECRET@'; |
55 |
695 |
ahitrov |
$self->{dreamkas_token} = '@DREAMKAS_TOKEN@'; |
56 |
693 |
ahitrov |
$self->{dreamkas_currency_code} = '@DREAMKAS_CURRENCY_CODE@'; |
57 |
|
|
$self->{dreamkas_tax_mode} = '@DREAMKAS_TAX_MODE@' || 'DEFAULT'; |
58 |
|
|
$self->{dreamkas_tax_nds} = '@DREAMKAS_TAX_NDS@' || 'NDS_NO_TAX'; |
59 |
|
|
$self->{dreamkas_device_id} = int('@DREAMKAS_DEVICE_ID@' || 0); |
60 |
|
|
$self->{dreamkas_test_mode} = int('@DREAMKAS_TEST_MODE@' || 0); |
61 |
|
|
|
62 |
|
|
$self->_init_(); |
63 |
|
|
$self; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
sub info { |
67 |
|
|
my $self = shift; |
68 |
|
|
return unless ref $self; |
69 |
|
|
|
70 |
|
|
for (sort keys %{$self->{attributes}}) { |
71 |
|
|
my $la = length $_; |
72 |
|
|
warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; |
73 |
|
|
} |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
sub _init_ { |
77 |
|
|
my $self = shift; |
78 |
|
|
|
79 |
|
|
# зашитая конфигурация плагина |
80 |
|
|
$self->{attributes}->{$_} = 'SCALAR' for qw( |
81 |
|
|
debug |
82 |
|
|
project |
83 |
|
|
tab_name |
84 |
|
|
|
85 |
|
|
db_type |
86 |
|
|
db_keepalive |
87 |
|
|
db_host |
88 |
|
|
db_port |
89 |
|
|
db_name |
90 |
|
|
db_user |
91 |
|
|
db_password |
92 |
|
|
store_method |
93 |
|
|
cascade |
94 |
|
|
db_prepare |
95 |
|
|
db_client_encoding |
96 |
|
|
|
97 |
|
|
memcached_enable |
98 |
|
|
memcached_enable_compress |
99 |
|
|
memcached_backend |
100 |
|
|
memcached_servers |
101 |
|
|
memcached_busy_lock |
102 |
|
|
memcached_delayed |
103 |
|
|
|
104 |
|
|
binary_directory |
105 |
|
|
data_directory |
106 |
|
|
images_directory |
107 |
|
|
preview |
108 |
|
|
); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
sub AUTOLOAD { |
112 |
|
|
my $self = shift; |
113 |
|
|
my $attribute = $AUTOLOAD; |
114 |
|
|
|
115 |
|
|
$attribute =~ s/.*:://; |
116 |
|
|
return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY |
117 |
|
|
|
118 |
|
|
if (!exists $self->{attributes}->{$attribute}) { |
119 |
|
|
warn "Contenido Error (money::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n"; |
120 |
|
|
return; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
$self->{$attribute} = shift @_ if $#_>=0; |
124 |
|
|
$self->{$attribute}; |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
1; |