Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
mailblock.php
1<?php
9
15
16Loc::loadMessages(__FILE__);
17
25{
29 public static function getListByType()
30 {
31 $resultTemplateList = array();
32 $arTemplateList = static::getList();
33 foreach($arTemplateList as $template)
34 $resultTemplateList[$template['TYPE']][] = $template;
35
36 return $resultTemplateList;
37 }
38
42 public static function getList()
43 {
44 $resultList = array();
45 $event = new Event('sender', 'OnPresetMailBlockList');
46 $event->send();
47
48 foreach ($event->getResults() as $eventResult)
49 {
50 if ($eventResult->getType() == EventResult::ERROR)
51 {
52 continue;
53 }
54
55 $eventResultParameters = $eventResult->getParameters();
56
57 if (!empty($eventResultParameters))
58 {
59 $resultList = array_merge($resultList, $eventResultParameters);
60 }
61 }
62
63 return $resultList;
64 }
65
69 public static function getBlockForVisualEditor()
70 {
71 $arResult = array(
72 'items' => array(),
73 'groups' => array(),
74 'rootDefaultFilename' => ''
75 );
76
77 $arGroupExists = array();
78 $arBlocksByType = static::getListByType();
79 foreach($arBlocksByType as $type => $arBlockList)
80 {
81 foreach($arBlockList as $blockNum => $arBlock)
82 {
83 $name = 'mailblock'.str_pad($blockNum+1, 4, '0', STR_PAD_LEFT);
84 $key = $arBlock['TYPE'].'/'.$name;
85 $arResult['items'][$key] = array(
86 'name' => $name,
87 'path' => $arBlock['TYPE'],
88 'title' => $arBlock['NAME'],
89 'thumb' => '',
90 'code' => $arBlock['HTML'],
91 'description' => empty($arBlock['DESC']) ? '' : $arBlock['DESC'],
92 'template' => '',
93 'level' => '',
94 'parent' => $arBlock['TYPE'],
95 );
96
97 if(!in_array($arBlock['TYPE'], $arGroupExists))
98 {
99 $arResult['groups'][] = array(
100 'path' => '',
101 'name' => $arBlock['TYPE'],
102 'level' => '0',
103 'default_name' => 'mailblockgroup' . (count($arGroupExists) + 1)
104 );
105 $arGroupExists[] = $arBlock['TYPE'];
106 }
107
108 } // foreach $arBlockList
109
110 } // foreach $arBlocksByType
111
112 if(isset($arResult['groups'][0]))
113 $arResult['rootDefaultFilename'] = $arResult['groups'][0]['default_name'];
114
115 return $arResult;
116 }
117}
static loadMessages($file)
Definition loc.php:64