81 public static function removePhpFromHtml($html, $previousHtml =
null, $canEditPhp =
false, $canUseLpa =
false)
83 if (!$canEditPhp && $canUseLpa)
85 $html = \LPA::Process($html, $previousHtml);
87 else if (!$canEditPhp)
89 $phpList = \PHPParser::ParseFile($html);
90 foreach($phpList as $php)
92 $surrogate =
'<span class="bxhtmled-surrogate" title="">'
93 . htmlspecialcharsbx(
Loc::getMessage(
'BLOCK_EDITOR_BLOCK_DYNAMIC_CONTENT'))
95 $html = str_replace($php[2], $surrogate, $html);
98 $html = str_replace([
'<?',
'?>'], [
'< ?',
'? >'], $html);
112 $site = $params[
'SITE'];
113 $html = $params[
'HTML'];
115 if(isset($params[
'FIELDS']))
117 $fields = $params[
'FIELDS'];
124 $canEditPhp = (isset($params[
'CAN_EDIT_PHP']) && $params[
'CAN_EDIT_PHP']);
125 $canUseLpa = (isset($params[
'CAN_USE_LPA']) && $params[
'CAN_USE_LPA']);
126 $html = static::removePhpFromHtml($html,
null, $canEditPhp, $canUseLpa);
128 if(is_object($GLOBALS[
"USER"]))
131 $fields[
'EMAIL_TO'] = htmlspecialcharsbx($GLOBALS[
"USER"]->GetEmail());
132 $fields[
'USER_ID'] = $GLOBALS[
"USER"]->GetID();
133 $fields[
'NAME'] = htmlspecialcharsbx($GLOBALS[
"USER"]->GetFirstName() ?: $GLOBALS[
"USER"]->GetLastName());
136 $siteDb = SiteTable::getList(array(
137 'select' => array(
'LID',
'SERVER_NAME',
'SITE_NAME',
'CULTURE_CHARSET'=>
'CULTURE.CHARSET'),
138 'filter' => array(
'LID' => $site)
140 if(!$siteRow = $siteDb->fetch())
142 $siteDb = SiteTable::getList(array(
143 'select' => array(
'LID',
'SERVER_NAME',
'SITE_NAME',
'CULTURE_CHARSET'=>
'CULTURE.CHARSET'),
144 'filter' => array(
'DEF' =>
true)
146 $siteRow = $siteDb->fetch();
149 $fields[
'SITE_NAME'] = $siteRow[
'SITE_NAME'];
150 $fields[
'SERVER_NAME'] = $siteRow[
'SERVER_NAME'];
151 $charset = $siteRow[
'CULTURE_CHARSET'];
153 $messageParams = array(
156 'BODY_TYPE' =>
'html',
157 'EMAIL_TO' =>
'#EMAIL_TO#',
160 'SITE' => $siteRow[
'LID'],
161 'CHARSET' => $charset,
164 $event =
new Event(
"main",
"OnBeforeBlockEditorMailPreview", $messageParams);
166 foreach ($event->getResults() as $eventResult)
168 if($eventResult->getType() !== EventResult::ERROR)
170 $messageParams = array_merge($messageParams, $eventResult->getParameters());
176 $html = $message->getMailBody();
179 $eventParams = array(
'HTML' => $html,
'INLINE_HTML' => $inlineHtml);
180 $event =
new Event(
"main",
"OnAfterBlockEditorMailPreview", $eventParams);
182 foreach ($event->getResults() as $eventResult)
184 if($eventResult->getType() !== EventResult::ERROR)
186 $eventParams = array_merge($eventParams, $eventResult->getParameters());
191 return $eventParams[
'INLINE_HTML'];