27 const LOCAL_DIR =
'/modules/sender/preset/template_toloka/';
29 private static function getFileContent($fileName)
31 $pathTemplate = Loader::getLocal(self::LOCAL_DIR . bx_basename($fileName) .
'.php');
32 $pathCSS = Loader::getLocal(self::LOCAL_DIR . bx_basename($fileName) .
'.css');
33 $pathJS = Loader::getLocal(self::LOCAL_DIR . bx_basename($fileName) .
'.js');
36 self::fileExists($pathTemplate) &&
37 self::fileExists($pathCSS) &&
38 self::fileExists($pathJS)
42 'template' => File::getFileContents($pathTemplate),
43 'css' => File::getFileContents($pathCSS),
44 'js' => File::getFileContents($pathJS),
50 private static function fileExists($path):bool
52 if($path && File::isFileExists($path))
69 if($templateType && $templateType !==
'BASE')
73 if($messageCode && $messageCode !==
Message\iBase::CODE_TOLOKA)
78 return self::getTemplates($templateId, $messageCode);
81 private static function getListByType()
86 'SEGMENT_CODES' => [],
91 'CODE' =>
'INSTRUCTION',
92 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_VIDEO_INSTRUCTION')
95 'CODE' =>
'DESCRIPTION',
96 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_VIDEO_DESCRIPTION')
100 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_VIDEO_TASKS')
103 'CODE' =>
'INPUT_VALUE',
104 'VALUE' => [
'video' => InputOutputSpec::TYPES[
'URL']]
107 'CODE' =>
'OUTPUT_VALUE',
108 'VALUE' => [
'result' => InputOutputSpec::TYPES[
'STRING']]
112 'VALUE' => self::getFileContent(
'video')
117 'CODE' =>
'leaflets',
118 'SEGMENT_CODES' => [],
119 'NAME' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_TITLE_LEAFLETS'),
120 'HINT' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_HINT_LEAFLETS'),
123 'CODE' =>
'INSTRUCTION',
124 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_LEAFLETS_INSTRUCTION')
127 'CODE' =>
'DESCRIPTION',
128 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_LEAFLETS_DESCRIPTION')
132 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_LEAFLETS_TASKS')
135 'CODE' =>
'INPUT_VALUE',
136 'VALUE' => [
'url' => InputOutputSpec::TYPES[
'URL']]
139 'CODE' =>
'OUTPUT_VALUE',
140 'VALUE' => [
'result' => InputOutputSpec::TYPES[
'STRING']]
144 'VALUE' => self::getFileContent(
'video')
148 'CODE' =>
'mystery_shopper',
149 'SEGMENT_CODES' => [],
150 'NAME' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_TITLE_MYSTERY'),
151 'HINT' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_HINT_MYSTERY'),
154 'CODE' =>
'INSTRUCTION',
155 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_MYSTERY_INSTRUCTION')
158 'CODE' =>
'DESCRIPTION',
159 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_MYSTERY_DESCRIPTION')
163 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_TOLOKA_MYSTERY_TASKS')
166 'CODE' =>
'INPUT_VALUE',
167 'VALUE' => [
'url' => InputOutputSpec::TYPES[
'URL']]
170 'CODE' =>
'OUTPUT_VALUE',
171 'VALUE' => [
'result' => InputOutputSpec::TYPES[
'STRING']]
175 'VALUE' => self::getFileContent(
'video')
182 private static function getTemplates($templateId =
null, $messageCode =
null)
184 $messageCodes = $messageCode ? array($messageCode) : [];
187 foreach (self::getListByType() as $item)
189 $originalCode = strtolower($item[
'CODE']);
190 $code =
'toloka_' . strtolower($item[
'CODE']);
191 if($templateId && $code !== $templateId)
200 'MESSAGE_CODE' => $messageCodes,
202 'HOT' => $item[
'HOT'] ??
'',
203 'ICON' => BX_ROOT . self::IMAGE_DIR .
"$originalCode.png",
204 'NAME' => $item[
'NAME'] ??
'',
205 'DESC' => $item[
'DESC'] ??
'',
206 'HINT' => $item[
'HINT'] ??
'',
207 'FIELDS' => array_merge(
212 'VALUE' => $item[
'TITLE'] ??
'',
216 'VALUE' => $item[
'TEXT'] ??
'',
219 'CODE' =>
'ALWAYS_ADD',
224 'DISPATCH' => $item[
'DISPATCH'] ??
'',
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)