Skip to content

Commit e495703

Browse files
committed
Init: Admin
1 parent e3eee76 commit e495703

File tree

1 file changed

+273
-0
lines changed

1 file changed

+273
-0
lines changed

Admin.php

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
<?php namespace Wc1c\Schemas\Productscleanercml;
2+
3+
defined('ABSPATH') || exit;
4+
5+
use Wc1c\Traits\SingletonTrait;
6+
use Wc1c\Traits\UtilityTrait;
7+
8+
/**
9+
* Admin
10+
*
11+
* @package Wc1c\Schemas\Productscleanercml
12+
*/
13+
class Admin
14+
{
15+
use SingletonTrait;
16+
use UtilityTrait;
17+
18+
/**
19+
* @var Core Schema core
20+
*/
21+
protected $core;
22+
23+
/**
24+
* @return Core
25+
*/
26+
public function core()
27+
{
28+
return $this->core;
29+
}
30+
31+
/**
32+
* @param Core $core
33+
*/
34+
public function setCore($core)
35+
{
36+
$this->core = $core;
37+
}
38+
39+
/**
40+
* @return void
41+
*/
42+
public function initConfigurationsFields()
43+
{
44+
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsReceiver'], 10, 1);
45+
46+
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsSync'], 30, 1);
47+
48+
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsClean'], 70, 1);
49+
50+
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsLogs'], 110, 1);
51+
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsOther'], 120, 1);
52+
}
53+
54+
/**
55+
* Configurations fields: receiver
56+
*
57+
* @param $fields
58+
*
59+
* @return array
60+
*/
61+
public function configurationsFieldsReceiver($fields)
62+
{
63+
$fields['title_receiver'] =
64+
[
65+
'title' => __('Receiving requests from 1C', 'wc1c'),
66+
'type' => 'title',
67+
'description' => __('Authorization of requests and regulation of algorithms for receiving requests for the Receiver from the 1C programs by CommerceML protocol.', 'wc1c'),
68+
];
69+
70+
$lazy_sign = $this->core()->configuration()->getMeta('receiver_lazy_sign');
71+
72+
if(empty($lazy_sign))
73+
{
74+
$lazy_sign = md5($this->core()->configuration()->getId() . time());
75+
$this->core()->configuration()->addMetaData('receiver_lazy_sign', $lazy_sign, true);
76+
$this->core()->configuration()->saveMetaData();
77+
}
78+
79+
$url_raw = get_site_url(null, '/?wc1c-receiver=' . $this->core()->configuration()->getId() . '&lazysign=' . $lazy_sign . '&get_param');
80+
$url_raw = '<p class="input-text p-2 bg-light regular-input wc1c_urls">' . esc_html($url_raw) . '</p>';
81+
82+
$fields['url_requests'] =
83+
[
84+
'title' => __('Website address', 'wc1c'),
85+
'type' => 'raw',
86+
'raw' => $url_raw,
87+
'description' => __('Specified in the exchange settings on the 1C side. The Recipient is located at this address, which will receive requests from 1C. When copying, you need to get rid of whitespace characters, if they are present.', 'wc1c'),
88+
];
89+
90+
$fields['user_login'] =
91+
[
92+
'title' => __('Username', 'wc1c'),
93+
'type' => 'text',
94+
'description' => __('Specified in 1C when setting up an exchange with a site on the 1C side. At the same time, work with data on the site is performed on behalf of the configuration owner, and not on behalf of the specified username.', 'wc1c'),
95+
'default' => '',
96+
'css' => 'min-width: 350px;',
97+
];
98+
99+
$fields['user_password'] =
100+
[
101+
'title' => __('User password', 'wc1c'),
102+
'type' => 'password',
103+
'description' => __('Specified in 1C paired with a username when setting up an exchange with a site on the 1C side. It is advisable not to specify the password for the current WordPress user.', 'wc1c'),
104+
'default' => '',
105+
'css' => 'min-width: 350px;',
106+
];
107+
108+
$fields['receiver_check_auth_key_disabled'] =
109+
[
110+
'title' => __('Request signature verification', 'wc1c'),
111+
'type' => 'checkbox',
112+
'label' => __('Check the checkbox to disable request signature verification. By default, validation is performed.', 'wc1c'),
113+
'description' => __('The setting disables authentication of requests from 1C. May be required only for very old versions of 1C. Enable only if there are errors in the request signature verification in the logs. If disabled, signature verification will be performed using the lazy signature from the lazysign parameter.', 'wc1c'),
114+
'default' => 'no'
115+
];
116+
117+
return $fields;
118+
}
119+
120+
/**
121+
* Configuration fields: other
122+
*
123+
* @param $fields
124+
*
125+
* @return array
126+
*/
127+
public function configurationsFieldsOther($fields)
128+
{
129+
$fields['title_other'] =
130+
[
131+
'title' => __('Other parameters', 'wc1c'),
132+
'type' => 'title',
133+
'description' => __('Change of data processing behavior for environment compatibility and so on.', 'wc1c'),
134+
];
135+
136+
$fields['php_post_max_size'] =
137+
[
138+
'title' => __('Maximum size of accepted requests', 'wc1c'),
139+
'type' => 'text',
140+
'description' => sprintf
141+
(
142+
'%s<br />%s <b>%s</b><br />%s',
143+
__('Enter the maximum size of accepted requests from 1C at a time in bytes. May be specified with a dimension suffix, such as 7M, where M = megabyte, K = kilobyte, G - gigabyte.', 'wc1c'),
144+
__('Current WC1C limit:', 'wc1c'),
145+
wc1c()->settings()->get('php_post_max_size', wc1c()->environment()->get('php_post_max_size')),
146+
__('Can only decrease the value, because it must not exceed the limits from the WC1C settings.', 'wc1c')
147+
),
148+
'default' => wc1c()->settings()->get('php_post_max_size', wc1c()->environment()->get('php_post_max_size')),
149+
'css' => 'min-width: 100px;',
150+
];
151+
152+
return $fields;
153+
}
154+
155+
/**
156+
* Configuration fields: sync
157+
*
158+
* @param $fields
159+
*
160+
* @return array
161+
*/
162+
public function configurationsFieldsSync($fields)
163+
{
164+
$fields['title_sync'] =
165+
[
166+
'title' => __('Sync options', 'wc1c'),
167+
'type' => 'title',
168+
'description' => sprintf
169+
('%s %s',
170+
__('Dispute resolution between existing products (goods) on the 1C side and in WooCommerce. For extended matching (example by SKU), must use the extension.', 'wc1c'),
171+
__('Products will only be deleted for found matching keys.', 'wc1c')
172+
),
173+
];
174+
175+
$fields['sync_by_id'] =
176+
[
177+
'title' => __('By external ID from 1C', 'wc1c'),
178+
'type' => 'checkbox',
179+
'label' => __('Check the box to enable. Enabled by default.', 'wc1c'),
180+
'description' => sprintf
181+
(
182+
'%s<hr> %s',
183+
__('When creating new products based on data from 1C, a universal global identifier from 1C is filled in for them. Can also fill in global identifiers manually for manually created products.', 'wc1c'),
184+
__('Enabling the option allows you to use the filled External ID to mark products (goods) as existing, and thereby run algorithms to update them.', 'wc1c')
185+
),
186+
'default' => 'yes'
187+
];
188+
189+
return $fields;
190+
}
191+
192+
/**
193+
* Configuration fields: clean
194+
*
195+
* @param $fields
196+
*
197+
* @return array
198+
*/
199+
public function configurationsFieldsClean($fields)
200+
{
201+
$fields['title_clean'] =
202+
[
203+
'title' => __('Cleaning options', 'wc1c'),
204+
'type' => 'title',
205+
'description' => __('Comprehensive settings for cleaning options.', 'wc1c'),
206+
];
207+
208+
$fields['clean'] =
209+
[
210+
'title' => __('Cleaning', 'wc1c'),
211+
'type' => 'checkbox',
212+
'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c'),
213+
'description' => __('All products received via the CommerceML protocol and matching keys for synchronization will be placed in the Recycle Bin.', 'wc1c'),
214+
'default' => 'no'
215+
];
216+
217+
$fields['clean_final'] =
218+
[
219+
'title' => __('Final removal', 'wc1c'),
220+
'type' => 'checkbox',
221+
'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c'),
222+
'description' => __('All products received via the CommerceML protocol and matching keys for synchronization will be permanently deleted from the Recycle Bin.', 'wc1c'),
223+
'default' => 'no'
224+
];
225+
226+
return $fields;
227+
}
228+
229+
/**
230+
* Configuration fields: logs
231+
*
232+
* @param $fields
233+
*
234+
* @return array
235+
*/
236+
public function configurationsFieldsLogs($fields)
237+
{
238+
$fields['title_logger'] =
239+
[
240+
'title' => __('Event logs', 'wc1c'),
241+
'type' => 'title',
242+
'description' => __('Maintaining event logs for the current configuration. You can view the logs through the extension or via FTP.', 'wc1c'),
243+
];
244+
245+
$fields['logger_level'] =
246+
[
247+
'title' => __('Level for events', 'wc1c'),
248+
'type' => 'select',
249+
'description' => __('All events of the selected level will be recorded in the log file. The higher the level, the less data is recorded.', 'wc1c'),
250+
'default' => '300',
251+
'options' =>
252+
[
253+
'logger_level' => __('Use level for main events', 'wc1c'),
254+
'100' => __('DEBUG (100)', 'wc1c'),
255+
'200' => __('INFO (200)', 'wc1c'),
256+
'250' => __('NOTICE (250)', 'wc1c'),
257+
'300' => __('WARNING (300)', 'wc1c'),
258+
'400' => __('ERROR (400)', 'wc1c'),
259+
],
260+
];
261+
262+
$fields['logger_files_max'] =
263+
[
264+
'title' => __('Maximum files', 'wc1c'),
265+
'type' => 'text',
266+
'description' => __('Log files created daily. This option on the maximum number of stored files. By default saved of the logs are for the last 30 days.', 'wc1c'),
267+
'default' => 10,
268+
'css' => 'min-width: 20px;',
269+
];
270+
271+
return $fields;
272+
}
273+
}

0 commit comments

Comments
 (0)