| 1 |
<?php |
| 2 |
|
| 3 |
namespace AcyMailing\Helpers; |
| 4 |
|
| 5 |
use AcyMailing\Classes\MailClass; |
| 6 |
use AcyMailing\Core\AcymObject; |
| 7 |
|
| 8 |
class PluginHelper extends AcymObject |
| 9 |
{ |
| 10 |
public $wraped = false; |
| 11 |
public $name = 'content'; |
| 12 |
public $mailerHelper; |
| 13 |
public $wrappedText = ''; |
| 14 |
public string $contextLanguage; |
| 15 |
|
| 16 |
public function getFormattedResult($elements, $parameter) |
| 17 |
{ |
| 18 |
if (count($elements) < 2) { |
| 19 |
return implode('', $elements); |
| 20 |
} |
| 21 |
|
| 22 |
$beforeAll = []; |
| 23 |
$beforeAll['table'] = '<table cellspacing="0" cellpadding="0" border="0" width="100%" class="elementstable">'."\n"; |
| 24 |
$beforeAll['ul'] = '<ul class="elementsul">'."\n"; |
| 25 |
$beforeAll['br'] = ''; |
| 26 |
|
| 27 |
$beforeBlock = []; |
| 28 |
$beforeBlock['table'] = '<tr class="elementstable_tr numrow{rownum}">'."\n"; |
| 29 |
$beforeBlock['ul'] = ''; |
| 30 |
$beforeBlock['br'] = ''; |
| 31 |
|
| 32 |
$beforeOne = []; |
| 33 |
$beforeOne['table'] = '<td valign="top" width="{equalwidth}" style="{padding}" class="elementstable_td numcol{numcol}" >'."\n"; |
| 34 |
$beforeOne['ul'] = '<li class="elementsul_li numrow{rownum}">'."\n"; |
| 35 |
$beforeOne['br'] = ''; |
| 36 |
|
| 37 |
$afterOne = []; |
| 38 |
$afterOne['table'] = '</td>'."\n"; |
| 39 |
$afterOne['ul'] = '</li>'."\n"; |
| 40 |
$afterOne['br'] = '<br />'."\n"; |
| 41 |
|
| 42 |
$afterBlock = []; |
| 43 |
$afterBlock['table'] = '</tr>'."\n"; |
| 44 |
$afterBlock['ul'] = ''; |
| 45 |
$afterBlock['br'] = ''; |
| 46 |
|
| 47 |
$afterAll = []; |
| 48 |
$afterAll['table'] = '</table>'."\n"; |
| 49 |
$afterAll['ul'] = '</ul>'."\n"; |
| 50 |
$afterAll['br'] = ''; |
| 51 |
|
| 52 |
|
| 53 |
$type = 'table'; |
| 54 |
$cols = 1; |
| 55 |
if (!empty($parameter->displaytype)) { |
| 56 |
$type = $parameter->displaytype; |
| 57 |
} |
| 58 |
if ($type == 'none') { |
| 59 |
return implode('', $elements); |
| 60 |
} |
| 61 |
if (!empty($parameter->cols)) { |
| 62 |
$cols = $parameter->cols; |
| 63 |
} |
| 64 |
|
| 65 |
$parameter->hpadding = !isset($parameter->hpadding) || is_null($parameter->hpadding) ? 10 : $parameter->hpadding; |
| 66 |
$parameter->vpadding = !isset($parameter->vpadding) || is_null($parameter->vpadding) ? 10 : $parameter->vpadding; |
| 67 |
|
| 68 |
$horizontalPadding = round($parameter->hpadding / 2); |
| 69 |
$verticalPadding = round($parameter->vpadding / 2); |
| 70 |
|
| 71 |
$string = $beforeAll[$type]; |
| 72 |
$a = 0; |
| 73 |
$numrow = 1; |
| 74 |
foreach ($elements as $key => $oneElement) { |
| 75 |
$topPadding = $verticalPadding.'px'; |
| 76 |
$rightPadding = $horizontalPadding.'px'; |
| 77 |
$bottomPadding = $verticalPadding.'px'; |
| 78 |
$leftPadding = $horizontalPadding.'px'; |
| 79 |
|
| 80 |
if ($a == $cols) { |
| 81 |
$string .= $afterBlock[$type]; |
| 82 |
$a = 0; |
| 83 |
$numrow++; |
| 84 |
} |
| 85 |
|
| 86 |
if ($a == 0) { |
| 87 |
$string .= str_replace('{rownum}', $numrow, $beforeBlock[$type]); |
| 88 |
$leftPadding = '0px'; |
| 89 |
} |
| 90 |
|
| 91 |
if ($a + 1 == $cols) $rightPadding = '0px'; |
| 92 |
if ($numrow == 1) $topPadding = '0px'; |
| 93 |
if (round(count($elements) / $cols) == $numrow) $bottomPadding = '0px'; |
| 94 |
|
| 95 |
$padding = 'padding: '.$topPadding.' '.$rightPadding.' '.$bottomPadding.' '.$leftPadding.' !important;'; |
| 96 |
|
| 97 |
$string .= str_replace('{numcol}', $a + 1, $beforeOne[$type]).$oneElement.$afterOne[$type]; |
| 98 |
$string = str_replace('{padding}', $padding, $string); |
| 99 |
$a++; |
| 100 |
} |
| 101 |
while ($cols > $a) { |
| 102 |
$string .= str_replace('{numcol}', $a + 1, $beforeOne[$type]).$afterOne[$type]; |
| 103 |
$a++; |
| 104 |
} |
| 105 |
|
| 106 |
$string .= $afterBlock[$type]; |
| 107 |
$string .= $afterAll[$type]; |
| 108 |
|
| 109 |
$equalwidth = intval(100 / $cols).'%'; |
| 110 |
|
| 111 |
$string = str_replace(['{equalwidth}'], [$equalwidth], $string); |
| 112 |
|
| 113 |
return $string; |
| 114 |
} |
| 115 |
|
| 116 |
public function formatString(&$replaceme, $mytag) |
| 117 |
{ |
| 118 |
if (!empty($mytag->part)) { |
| 119 |
$parts = explode(' ', $replaceme); |
| 120 |
if ($mytag->part == 'last') { |
| 121 |
$replaceme = count($parts) > 1 ? end($parts) : ''; |
| 122 |
} else { |
| 123 |
if (is_numeric($mytag->part) && count($parts) >= $mytag->part) { |
| 124 |
$replaceme = $parts[$mytag->part - 1]; |
| 125 |
} else { |
| 126 |
$replaceme = reset($parts); |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
if (!empty($mytag->type)) { |
| 132 |
if (empty($mytag->format)) { |
| 133 |
$mytag->format = acym_translation('ACYM_DATE_FORMAT_LC3'); |
| 134 |
} |
| 135 |
if ($mytag->type == 'date') { |
| 136 |
$replaceme = acym_getDate(acym_getTime($replaceme), $mytag->format); |
| 137 |
} elseif ($mytag->type == 'time') { |
| 138 |
$replaceme = acym_getDate($replaceme, $mytag->format); |
| 139 |
} elseif ($mytag->type == 'diff') { |
| 140 |
try { |
| 141 |
$date = $replaceme; |
| 142 |
if (is_numeric($date)) { |
| 143 |
$date = acym_getDate($replaceme, '%Y-%m-%d %H:%M:%S'); |
| 144 |
} |
| 145 |
$dateObj = new \DateTime($date); |
| 146 |
$nowObj = new \DateTime(); |
| 147 |
$diff = $dateObj->diff($nowObj); |
| 148 |
$replaceme = $diff->format($mytag->format); |
| 149 |
} catch (\Exception $e) { |
| 150 |
$replaceme = 'Error using the "diff" parameter in your tag. Please make sure the DateTime() and diff() functions are available on your server.'; |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
if (!empty($mytag->lower) || !empty($mytag->lowercase)) { |
| 156 |
$replaceme = function_exists('mb_strtolower') ? mb_strtolower($replaceme, 'UTF-8') : strtolower($replaceme); |
| 157 |
} |
| 158 |
if (!empty($mytag->upper) || !empty($mytag->uppercase)) { |
| 159 |
$replaceme = function_exists('mb_strtoupper') ? mb_strtoupper($replaceme, 'UTF-8') : strtoupper($replaceme); |
| 160 |
} |
| 161 |
if (!empty($mytag->ucwords)) { |
| 162 |
$replaceme = ucwords($replaceme); |
| 163 |
} |
| 164 |
if (!empty($mytag->ucfirst)) { |
| 165 |
$replaceme = ucfirst($replaceme); |
| 166 |
} |
| 167 |
if (isset($mytag->rtrim)) { |
| 168 |
$replaceme = empty($mytag->rtrim) ? rtrim($replaceme) : rtrim($replaceme, $mytag->rtrim); |
| 169 |
} |
| 170 |
if (!empty($mytag->urlencode)) { |
| 171 |
$replaceme = urlencode($replaceme); |
| 172 |
} |
| 173 |
if (!empty($mytag->substr)) { |
| 174 |
$args = explode(',', $mytag->substr); |
| 175 |
if (isset($args[1])) { |
| 176 |
$replaceme = substr($replaceme, intval($args[0]), intval($args[1])); |
| 177 |
} else { |
| 178 |
$replaceme = substr($replaceme, intval($args[0])); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
if (!empty($mytag->maxheight) || !empty($mytag->maxwidth)) { |
| 184 |
$imageHelper = new ImageHelper(); |
| 185 |
$imageHelper->maxHeight = empty($mytag->maxheight) ? 999 : $mytag->maxheight; |
| 186 |
$imageHelper->maxWidth = empty($mytag->maxwidth) ? 999 : $mytag->maxwidth; |
| 187 |
$replaceme = $imageHelper->resizePictures($replaceme); |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
public function replaceVideos(&$text) |
| 192 |
{ |
| 193 |
$text = preg_replace( |
| 194 |
'#\[embed=videolink][^}]*youtube[^=]*=([^"/}]*)[^}]*}\[/embed]#i', |
| 195 |
'<a target="_blank" href="https://www.youtube.com/watch?v=$1"><img src="https://img.youtube.com/vi/$1/0.jpg"/></a>', |
| 196 |
$text |
| 197 |
); |
| 198 |
$text = preg_replace( |
| 199 |
'#<video[^>]*youtube\.com/embed/([^"/]*)[^>]*>[^>]*</video>#i', |
| 200 |
'<a target="_blank" href="https://www.youtube.com/watch?v=$1"><img src="https://img.youtube.com/vi/$1/0.jpg"/></a>', |
| 201 |
$text |
| 202 |
); |
| 203 |
$text = preg_replace( |
| 204 |
'#{JoooidContent[^}]*youtube[^}]*id"[^"]*"([^}"]*)"[^}]*}#i', |
| 205 |
'<a target="_blank" href="https://www.youtube.com/watch?v=$1"><img src="https://img.youtube.com/vi/$1/0.jpg"/></a>', |
| 206 |
$text |
| 207 |
); |
| 208 |
$text = preg_replace( |
| 209 |
'#<iframe[^>]*src="[^"]*youtube[^"]*embed/([^"?]*)(\?[^"]*)?"[^>]*>[^<]*</iframe>#Uis', |
| 210 |
'<a target="_blank" href="https://www.youtube.com/watch?v=$1"><img src="https://img.youtube.com/vi/$1/0.jpg"/></a>', |
| 211 |
$text |
| 212 |
); |
| 213 |
|
| 214 |
$text = preg_replace( |
| 215 |
'#{youtube}[^{]+v=([^{&]+)(&[^{]*)?{/youtube}#Uis', |
| 216 |
'<a target="_blank" href="https://www.youtube.com/watch?v=$1"><img src="https://img.youtube.com/vi/$1/0.jpg"/></a>', |
| 217 |
$text |
| 218 |
); |
| 219 |
|
| 220 |
$text = preg_replace('#{vimeo}(https://vimeo.com/[^{]+){/vimeo}#Uis', '<iframe src="$1"></iframe>', $text); |
| 221 |
$text = preg_replace('#{vimeo}([^{]+){/vimeo}#Uis', '<iframe src="https://player.vimeo.com/video/$1"></iframe>', $text); |
| 222 |
|
| 223 |
if (preg_match_all('#<iframe[^>]*src="[^"]*vimeo[^"]*/(\d+)([&/\?][^"]*)?"[^>]*>[^<]*</iframe>#Uis', $text, $matches)) { |
| 224 |
foreach ($matches[1] as $key => $match) { |
| 225 |
$hash = acym_fileGetContent('https://vimeo.com/api/v2/video/'.$match.'.php'); |
| 226 |
$hash = @unserialize($hash); |
| 227 |
if (empty($hash)) continue; |
| 228 |
|
| 229 |
if (strpos($matches[0][$key], ' width="') !== false) { |
| 230 |
$extension = substr($hash[0]['thumbnail_large'], strrpos($hash[0]['thumbnail_large'], '.')); |
| 231 |
preg_match('#width="([^"]*)"#Uis', $matches[0][$key], $width); |
| 232 |
|
| 233 |
$replace = strpos($hash[0]['thumbnail_large'], '_') === false ? '.' : '_'; |
| 234 |
$hash[0]['thumbnail_large'] = substr($hash[0]['thumbnail_large'], 0, strrpos($hash[0]['thumbnail_large'], $replace)).'_'.$width[1].$extension; |
| 235 |
} |
| 236 |
$thumbnail = 'https://i.vimeocdn.com/filter/overlay?src='.urlencode($hash[0]['thumbnail_large']); |
| 237 |
$thumbnail .= '&src='.urlencode('https://f.vimeocdn.com/p/images/crawler_play.png'); |
| 238 |
|
| 239 |
$text = str_replace( |
| 240 |
$matches[0][$key], |
| 241 |
'<a target="_blank" href="'.acym_escape($hash[0]['url']).'"><img class="donotresize" alt="" src="'.acym_escape($thumbnail).'" /></a>', |
| 242 |
$text |
| 243 |
); |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
$text = preg_replace('#\[embed=videolink][^}]*video":"([^"]*)[^}]*}\[/embed]#i', '<a target="_blank" href="$1"><img src="'.ACYM_IMAGES.'/video.png"/></a>', $text); |
| 248 |
$text = preg_replace('#<video[^>]*src="([^"]*)"[^>]*>[^>]*</video>#i', '<a target="_blank" href="$1"><img src="'.ACYM_IMAGES.'/video.png"/></a>', $text); |
| 249 |
} |
| 250 |
|
| 251 |
private function _convertbase64pictures(&$html) |
| 252 |
{ |
| 253 |
if (!preg_match_all('#<img[^>]*src=("data:image/([^;]{1,5});base64[^"]*")([^>]*)>#Uis', $html, $resultspictures)) { |
| 254 |
return; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
$dest = ACYM_MEDIA.'resized'.DS; |
| 260 |
acym_createDir($dest); |
| 261 |
foreach ($resultspictures[2] as $i => $extension) { |
| 262 |
$pictname = md5($resultspictures[1][$i]).'.'.$extension; |
| 263 |
$picturl = ACYM_LIVE.str_replace(DS, '/', ACYM_MEDIA_FOLDER).'resized/'.$pictname; |
| 264 |
$pictPath = $dest.$pictname; |
| 265 |
$pictCode = trim($resultspictures[1][$i], '"'); |
| 266 |
if (file_exists($pictPath)) { |
| 267 |
$html = str_replace($pictCode, $picturl, $html); |
| 268 |
continue; |
| 269 |
} |
| 270 |
|
| 271 |
if (!ini_get('allow_url_fopen')) { |
| 272 |
continue; |
| 273 |
} |
| 274 |
|
| 275 |
$getfunction = ''; |
| 276 |
switch ($extension) { |
| 277 |
case 'gif': |
| 278 |
$getfunction = 'ImageCreateFromGIF'; |
| 279 |
break; |
| 280 |
case 'jpg': |
| 281 |
case 'jpeg': |
| 282 |
$getfunction = 'ImageCreateFromJPEG'; |
| 283 |
break; |
| 284 |
case 'png': |
| 285 |
$getfunction = 'ImageCreateFromPNG'; |
| 286 |
break; |
| 287 |
} |
| 288 |
|
| 289 |
if (empty($getfunction) || !function_exists($getfunction)) { |
| 290 |
continue; |
| 291 |
} |
| 292 |
|
| 293 |
$img = $getfunction($pictCode); |
| 294 |
|
| 295 |
if (in_array($extension, ['gif', 'png'])) { |
| 296 |
imagealphablending($img, false); |
| 297 |
imagesavealpha($img, false); |
| 298 |
} |
| 299 |
|
| 300 |
ob_start(); |
| 301 |
switch ($extension) { |
| 302 |
case 'gif': |
| 303 |
$status = imagegif($img); |
| 304 |
break; |
| 305 |
case 'jpg': |
| 306 |
case 'jpeg': |
| 307 |
$status = imagejpeg($img, null, 100); |
| 308 |
break; |
| 309 |
case 'png': |
| 310 |
$status = imagepng($img, null, 1); |
| 311 |
break; |
| 312 |
} |
| 313 |
$imageContent = ob_get_clean(); |
| 314 |
$status = $status && acym_writeFile($pictPath, $imageContent); |
| 315 |
|
| 316 |
if (!$status) { |
| 317 |
continue; |
| 318 |
} |
| 319 |
$html = str_replace($pictCode, $picturl, $html); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
public function cleanHtml(&$html) |
| 324 |
{ |
| 325 |
$this->_convertbase64pictures($html); |
| 326 |
|
| 327 |
$pregreplace = []; |
| 328 |
$pregreplace['#<tr([^>"]*>([^<]*<td[^>]*>[ \n\s]*<img[^>]*>[ \n\s]*</ *td[^>]*>[ \n\s]*)*</ *tr)#Uis'] = '<tr style="line-height: 0px;" $1'; |
| 329 |
$pregreplace['#<td(((?!style|>).)*>[ \n\s]*(<a[^>]*>)?[ \n\s]*<img[^>]*>[ \n\s]*(</a[^>]*>)?[ \n\s]*</ *td)#Uis'] = '<td style="line-height: 0px;" $1'; |
| 330 |
|
| 331 |
$pregreplace['#{tab[ =][^}]*}#is'] = ''; |
| 332 |
$pregreplace['#{/tabs}#is'] = ''; |
| 333 |
$pregreplace['#{jcomments\s+(on|off|lock)}#is'] = ''; |
| 334 |
|
| 335 |
$pregreplace["#(onmouseout|onmouseover|onclick|onfocus|onload|onblur) *= *\"(?:(?!\").)*\"#Ui"] = ''; |
| 336 |
$pregreplace["#< *script(?:(?!< */ *script *>).)*< */ *script *>#Uis"] = ''; |
| 337 |
$pregreplace["#< *iframe(?:(?!< */ *iframe *>).)*< */ *iframe *>#Uis"] = ''; |
| 338 |
|
| 339 |
$pregreplace['#(<p style=")([^>]*>\s*<img *[^>]*margin-left: auto; margin-right: auto;[^>]*>\s*</p>)#Uis'] = '$1text-align: center;$2'; |
| 340 |
$pregreplace['#(<img [^>]*src="[^"]+\.webp"[^>]*>)#Uis'] = '<!--[if !mso]><!-->$1<!--<![endif]-->'; |
| 341 |
|
| 342 |
$newbody = preg_replace(array_keys($pregreplace), $pregreplace, $html); |
| 343 |
if (!empty($newbody)) { |
| 344 |
$html = $newbody; |
| 345 |
} |
| 346 |
|
| 347 |
$body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', [$this, '_convertSpaces'], $html); |
| 348 |
if (!empty($body)) $html = $body; |
| 349 |
|
| 350 |
$html = acym_cmsCleanHtml($html); |
| 351 |
} |
| 352 |
|
| 353 |
public function _convertSpaces($matches) |
| 354 |
{ |
| 355 |
return "src='".str_replace(' ', '%20', $matches[1])."'"; |
| 356 |
} |
| 357 |
|
| 358 |
public function replaceTags(&$email, $tags, $html = false) |
| 359 |
{ |
| 360 |
if (empty($tags)) return; |
| 361 |
|
| 362 |
$htmlVars = ['body']; |
| 363 |
$textVars = [ |
| 364 |
'subject', |
| 365 |
'AltBody', |
| 366 |
'From', |
| 367 |
'FromName', |
| 368 |
'ReplyTo', |
| 369 |
'ReplyName', |
| 370 |
'bcc', |
| 371 |
'cc', |
| 372 |
'fromname', |
| 373 |
'fromemail', |
| 374 |
'replyname', |
| 375 |
'replyemail', |
| 376 |
'params', |
| 377 |
'preheader', |
| 378 |
]; |
| 379 |
|
| 380 |
$variables = array_merge($htmlVars, $textVars); |
| 381 |
|
| 382 |
if ($html) { |
| 383 |
if (empty($this->mailerHelper)) { |
| 384 |
$this->mailerHelper = new MailerHelper(); |
| 385 |
} |
| 386 |
|
| 387 |
$textreplace = []; |
| 388 |
foreach ($tags as $i => $replacement) { |
| 389 |
if (isset($textreplace[$i])) continue; |
| 390 |
$textreplace[$i] = $this->mailerHelper->textVersion($replacement, true); |
| 391 |
} |
| 392 |
} else { |
| 393 |
$textreplace = $tags; |
| 394 |
} |
| 395 |
|
| 396 |
foreach ($variables as $var) { |
| 397 |
if (empty($email->$var)) continue; |
| 398 |
$email->$var = $this->replaceDText($email->$var, in_array($var, $htmlVars) ? $tags : $textreplace); |
| 399 |
} |
| 400 |
} |
| 401 |
|
| 402 |
public function replaceDText($text, $replacement) |
| 403 |
{ |
| 404 |
if (is_array($text)) { |
| 405 |
foreach ($text as $i => &$oneCell) { |
| 406 |
if (empty($oneCell)) continue; |
| 407 |
$oneCell = $this->replaceDText($oneCell, $replacement); |
| 408 |
} |
| 409 |
} elseif (is_string($text) && !empty($text)) { |
| 410 |
foreach ($replacement as $code => $value) { |
| 411 |
$codes = [$code, urlencode($code)]; |
| 412 |
if (is_null($value)) { |
| 413 |
$value = ''; |
| 414 |
} |
| 415 |
$safePregValue = str_replace('$', '\$', $value); |
| 416 |
|
| 417 |
foreach ($codes as $oneCode) { |
| 418 |
$text = preg_replace( |
| 419 |
'#<span[^>]+'.preg_quote($oneCode, '#').'.+</em>[^<]*</span>#Uis', |
| 420 |
$safePregValue, |
| 421 |
$text |
| 422 |
); |
| 423 |
|
| 424 |
$text = preg_replace( |
| 425 |
'#(<tr[^>]+)data-dynamic="'.preg_quote($oneCode, '#').'"([^>]+>[^<]*<td[^>]*>).+</i>[^<]*</td>[^<]*</tr>#Uis', |
| 426 |
'${1}${2}'.$safePregValue.'</td></tr>', |
| 427 |
$text |
| 428 |
); |
| 429 |
|
| 430 |
$text = str_replace($oneCode, $value, $text); |
| 431 |
} |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
return $text; |
| 436 |
} |
| 437 |
|
| 438 |
public function extractTags($email, $tagfamily) |
| 439 |
{ |
| 440 |
$results = []; |
| 441 |
|
| 442 |
$match = '#(?:{|%7B)'.$tagfamily.'(?:%3A|\\:)(.*)(?:}|%7D)#Ui'; |
| 443 |
$variables = [ |
| 444 |
'subject', |
| 445 |
'AltBody', |
| 446 |
'body', |
| 447 |
'From', |
| 448 |
'FromName', |
| 449 |
'ReplyTo', |
| 450 |
'ReplyName', |
| 451 |
'bcc', |
| 452 |
'cc', |
| 453 |
'fromname', |
| 454 |
'fromemail', |
| 455 |
'replyname', |
| 456 |
'replyemail', |
| 457 |
'params', |
| 458 |
'preheader', |
| 459 |
]; |
| 460 |
$found = false; |
| 461 |
foreach ($variables as $var) { |
| 462 |
if (empty($email->$var)) continue; |
| 463 |
|
| 464 |
if (is_array($email->$var)) { |
| 465 |
foreach ($email->$var as $i => $arrayField) { |
| 466 |
if (empty($arrayField)) continue; |
| 467 |
|
| 468 |
if (is_array($arrayField)) { |
| 469 |
foreach ($arrayField as $a => $oneval) { |
| 470 |
$found = preg_match_all($match, $oneval, $results[$var.$i.'-'.$a]) || $found; |
| 471 |
if (empty($results[$var.$i.'-'.$a][0])) unset($results[$var.$i.'-'.$a]); |
| 472 |
} |
| 473 |
} else { |
| 474 |
$found = preg_match_all($match, $arrayField, $results[$var.$i]) || $found; |
| 475 |
if (empty($results[$var.$i][0])) unset($results[$var.$i]); |
| 476 |
} |
| 477 |
} |
| 478 |
} else { |
| 479 |
$found = preg_match_all($match, $email->$var, $results[$var]) || $found; |
| 480 |
if (empty($results[$var][0])) unset($results[$var]); |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
if (!$found) { |
| 485 |
return []; |
| 486 |
} |
| 487 |
|
| 488 |
$tags = []; |
| 489 |
foreach ($results as $var => $allresults) { |
| 490 |
foreach ($allresults[0] as $i => $oneTag) { |
| 491 |
if (isset($tags[$oneTag])) { |
| 492 |
continue; |
| 493 |
} |
| 494 |
$tags[$oneTag] = $this->extractTag($allresults[1][$i]); |
| 495 |
} |
| 496 |
} |
| 497 |
|
| 498 |
return $tags; |
| 499 |
} |
| 500 |
|
| 501 |
public function extractTag($oneTag) |
| 502 |
{ |
| 503 |
$oneTag = str_replace(['[time]+', '[time]-'], [urlencode('[time]+'), urlencode('[time]-')], $oneTag); |
| 504 |
$arguments = explode('|', strip_tags(urldecode($oneTag))); |
| 505 |
$tag = new \stdClass(); |
| 506 |
$tag->id = $arguments[0]; |
| 507 |
$tag->default = ''; |
| 508 |
for ($i = 1, $a = count($arguments) ; $i < $a ; $i++) { |
| 509 |
$args = explode(':', $arguments[$i], 2); |
| 510 |
$arg0 = trim($args[0]); |
| 511 |
if (empty($arg0)) continue; |
| 512 |
|
| 513 |
if (isset($args[1])) { |
| 514 |
$tag->$arg0 = $args[1]; |
| 515 |
if (isset($args[2])) { |
| 516 |
$tag->{$args[0]} .= ':'.$args[2]; |
| 517 |
} |
| 518 |
} else { |
| 519 |
$tag->$arg0 = true; |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
return $tag; |
| 524 |
} |
| 525 |
|
| 526 |
public function wrapText($text, $tag) |
| 527 |
{ |
| 528 |
$this->wraped = false; |
| 529 |
|
| 530 |
if (!empty($tag->wrap)) $tag->wrap = intval($tag->wrap); |
| 531 |
if (empty($tag->wrap)) return $text; |
| 532 |
|
| 533 |
$allowedTags = [ |
| 534 |
'b', |
| 535 |
'strong', |
| 536 |
'i', |
| 537 |
'em', |
| 538 |
'a', |
| 539 |
'p', |
| 540 |
'div', |
| 541 |
'h2', |
| 542 |
'h3', |
| 543 |
'h4', |
| 544 |
'h5', |
| 545 |
'h6', |
| 546 |
]; |
| 547 |
|
| 548 |
$aloneAllowedTags = [ |
| 549 |
'br', |
| 550 |
'img', |
| 551 |
]; |
| 552 |
|
| 553 |
$newText = strip_tags($text, '<'.implode('><', array_merge($allowedTags, $aloneAllowedTags)).'>'); |
| 554 |
|
| 555 |
$newText = preg_replace('/^(\s|\n|(<br[^>]*>))+/i', '', trim($newText)); |
| 556 |
$newText = preg_replace('/(\s|\n|(<br[^>]*>))+$/i', '', trim($newText)); |
| 557 |
|
| 558 |
$newText = str_replace(['<', '>'], ['<', '>'], $newText); |
| 559 |
|
| 560 |
$numChar = strlen($newText); |
| 561 |
|
| 562 |
$numCharStrip = strlen(strip_tags($newText)); |
| 563 |
|
| 564 |
if ($numCharStrip <= $tag->wrap) { |
| 565 |
return $newText; |
| 566 |
} |
| 567 |
|
| 568 |
$this->wraped = true; |
| 569 |
|
| 570 |
$open = []; |
| 571 |
|
| 572 |
$write = true; |
| 573 |
|
| 574 |
$countStripChar = 0; |
| 575 |
|
| 576 |
for ($i = 0 ; $i < $numChar ; $i++) { |
| 577 |
if ($newText[$i] == '<') { |
| 578 |
foreach ($allowedTags as $oneAllowedTag) { |
| 579 |
if ($numChar >= ($i + strlen($oneAllowedTag) + 1) && substr($newText, $i, strlen($oneAllowedTag) + 1) == '<'.$oneAllowedTag && (in_array( |
| 580 |
$newText[$i + strlen($oneAllowedTag) + 1], |
| 581 |
[' ', '>'] |
| 582 |
))) { |
| 583 |
$write = false; |
| 584 |
$open[] = '</'.$oneAllowedTag.'>'; |
| 585 |
} |
| 586 |
|
| 587 |
if ($numChar >= ($i + strlen($oneAllowedTag) + 2) && substr($newText, $i, strlen($oneAllowedTag) + 2) == '</'.$oneAllowedTag) { |
| 588 |
if (end($open) == '</'.$oneAllowedTag.'>') { |
| 589 |
array_pop($open); |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
|
| 594 |
foreach ($aloneAllowedTags as $oneAllowedTag) { |
| 595 |
if ($numChar >= ($i + strlen($oneAllowedTag) + 1) && substr($newText, $i, strlen($oneAllowedTag) + 1) == '<'.$oneAllowedTag && (in_array( |
| 596 |
$newText[$i + strlen($oneAllowedTag) + 1], |
| 597 |
[' ', '/', '>'] |
| 598 |
))) { |
| 599 |
$write = false; |
| 600 |
} |
| 601 |
} |
| 602 |
} |
| 603 |
|
| 604 |
if ($write) { |
| 605 |
$countStripChar++; |
| 606 |
} |
| 607 |
|
| 608 |
if ($newText[$i] == ">") { |
| 609 |
$write = true; |
| 610 |
} |
| 611 |
|
| 612 |
if ($newText[$i] == " " && $countStripChar >= $tag->wrap && $write) { |
| 613 |
$newText = substr($newText, 0, $i).'...'; |
| 614 |
|
| 615 |
$open = array_reverse($open); |
| 616 |
$newText = $newText.implode('', $open); |
| 617 |
|
| 618 |
break; |
| 619 |
} |
| 620 |
} |
| 621 |
|
| 622 |
$newText = preg_replace('/^(\s|\n|(<br[^>]*>))+/i', '', trim($newText)); |
| 623 |
$newText = preg_replace('/(\s|\n|(<br[^>]*>))+$/i', '', trim($newText)); |
| 624 |
|
| 625 |
return $newText; |
| 626 |
} |
| 627 |
|
| 628 |
public function getStandardDisplay($format) |
| 629 |
{ |
| 630 |
if (empty($format->tag->format)) $format->tag->format = 'TOP_LEFT'; |
| 631 |
if (!in_array($format->tag->format, ['TOP_LEFT', 'TOP_RIGHT', 'TITLE_IMG', 'TITLE_IMG_RIGHT', 'CENTER_IMG', 'TOP_IMG', 'COL_LEFT', 'COL_RIGHT'])) { |
| 632 |
$format->tag->format = 'TOP_LEFT'; |
| 633 |
} |
| 634 |
|
| 635 |
$invertValues = [ |
| 636 |
'TOP_LEFT' => 'TOP_RIGHT', |
| 637 |
'TITLE_IMG' => 'TITLE_IMG_RIGHT', |
| 638 |
'COL_LEFT' => 'COL_RIGHT', |
| 639 |
'TOP_RIGHT' => 'TOP_LEFT', |
| 640 |
'TITLE_IMG_RIGHT' => 'TITLE_IMG', |
| 641 |
'COL_RIGHT' => 'COL_LEFT', |
| 642 |
]; |
| 643 |
if (!empty($format->tag->invert) && !empty($invertValues[$format->tag->format])) { |
| 644 |
$format->tag->format = $invertValues[$format->tag->format]; |
| 645 |
} |
| 646 |
|
| 647 |
$image = ''; |
| 648 |
if (!empty($format->imagePath)) { |
| 649 |
$style = ''; |
| 650 |
$linkStyle = ''; |
| 651 |
|
| 652 |
if (in_array($format->tag->format, ['TOP_LEFT', 'TITLE_IMG'])) { |
| 653 |
$style = 'left'; |
| 654 |
} elseif (in_array($format->tag->format, ['TOP_RIGHT', 'TITLE_IMG_RIGHT'])) { |
| 655 |
$style = 'right'; |
| 656 |
} |
| 657 |
|
| 658 |
if (!empty($style)) { |
| 659 |
$linkStyle = 'style="float:'.$style.';"'; |
| 660 |
|
| 661 |
if ($style === 'left') { |
| 662 |
$style = 'style="float:left; margin-right: 7px; margin-bottom: 7px;"'; |
| 663 |
} else { |
| 664 |
$style = 'style="float:right; margin-left: 7px; margin-bottom: 7px;"'; |
| 665 |
} |
| 666 |
} |
| 667 |
|
| 668 |
preg_match('#src="([^"]+)"#Uis', $format->imagePath, $matches); |
| 669 |
if (!empty($matches[1])) $format->imagePath = $matches[1]; |
| 670 |
$altImage = !empty($format->altImage) ? $format->altImage : ''; |
| 671 |
$image = '<img class="content_main_image" alt="'.acym_escape($altImage).'" src="'.$format->imagePath.'" '.$style.' />'; |
| 672 |
|
| 673 |
if (!empty($format->imageCaption) && !in_array($format->tag->format, ['TITLE_IMG', 'TITLE_IMG_RIGHT'])) { |
| 674 |
$image .= '<p class="content_main_image_caption">'.acym_escape($format->imageCaption).'</p>'; |
| 675 |
} |
| 676 |
} |
| 677 |
|
| 678 |
$result = ''; |
| 679 |
if (in_array($format->tag->format, ['TITLE_IMG', 'TITLE_IMG_RIGHT'])) { |
| 680 |
$format->title = $image.$format->title; |
| 681 |
$image = ''; |
| 682 |
} |
| 683 |
|
| 684 |
if (!empty($format->link) && !empty($image) && !empty($format->tag->clickableimg)) { |
| 685 |
$image = '<a target="_blank" href="'.$format->link.'" '.$linkStyle.'>'.$image.'</a>'; |
| 686 |
} |
| 687 |
|
| 688 |
if ($format->tag->format === 'TOP_IMG' && !empty($image)) { |
| 689 |
$result = $image; |
| 690 |
$image = ''; |
| 691 |
} |
| 692 |
|
| 693 |
if (in_array($format->tag->format, ['COL_LEFT', 'COL_RIGHT'])) { |
| 694 |
$maxWidth = empty($format->tag->maxwidth) ? '' : ' width: '.$format->tag->maxwidth.'px;'; |
| 695 |
if (empty($image)) { |
| 696 |
$format->tag->format = 'TOP_LEFT'; |
| 697 |
} else { |
| 698 |
$result = '<table><tr><td valign="middle" style="vertical-align: middle; padding-right: 7px;" class="acyleftcol">'; |
| 699 |
if ($format->tag->format === 'COL_LEFT') { |
| 700 |
$result = '<table><tr><td valign="middle" style="vertical-align: middle; padding-right: 7px; '.$maxWidth.'" class="acyleftcol">'; |
| 701 |
$result .= $image.'</td><td valign="top" class="acyrightcol">'; |
| 702 |
} |
| 703 |
} |
| 704 |
} |
| 705 |
|
| 706 |
if (!empty($format->title)) { |
| 707 |
if (!empty($format->link) && !empty($format->tag->clickable)) { |
| 708 |
if (empty($format->tag->type) || $format->tag->type !== 'title') { |
| 709 |
$format->title = '<h2 class="acym_title">'.$format->title.'</h2>'; |
| 710 |
} |
| 711 |
|
| 712 |
$title = '<a'; |
| 713 |
if (!empty($format->tag->type) && $format->tag->type === 'title') $title .= ' class="acym_title"'; |
| 714 |
$title .= ' href="'.$format->link.'" target="_blank" name="'.$this->name.'-'.$format->tag->id.'">'; |
| 715 |
$title .= $format->title; |
| 716 |
$title .= '</a>'; |
| 717 |
$format->title = $title; |
| 718 |
} else { |
| 719 |
if (empty($format->tag->type) || $format->tag->type != 'title') { |
| 720 |
$format->title = '<h2 class="acym_title">'.$format->title.'</h2>'; |
| 721 |
} |
| 722 |
} |
| 723 |
|
| 724 |
$result .= $format->title; |
| 725 |
} |
| 726 |
|
| 727 |
if (!empty($format->afterTitle)) { |
| 728 |
$result .= $format->afterTitle; |
| 729 |
} |
| 730 |
|
| 731 |
if (!empty($format->description)) { |
| 732 |
$format->description = $this->wrapText($format->description, $format->tag); |
| 733 |
} |
| 734 |
$this->wrappedText = $format->description; |
| 735 |
|
| 736 |
|
| 737 |
$rowText = '<div class="acydescription">'; |
| 738 |
$endRow = '</div><br />'; |
| 739 |
if (in_array($format->tag->format, ['TOP_LEFT', 'TOP_RIGHT', 'TITLE_IMG', 'TITLE_IMG_RIGHT', 'TOP_IMG'])) { |
| 740 |
if (!empty($image) || !empty($format->description)) { |
| 741 |
$result .= $rowText.$image.$format->description.$endRow; |
| 742 |
} |
| 743 |
} elseif ($format->tag->format == 'CENTER_IMG') { |
| 744 |
if (!empty($image)) { |
| 745 |
$result .= '<div class="acymainimage">'.$image.$endRow; |
| 746 |
} |
| 747 |
|
| 748 |
if (!empty($format->description)) { |
| 749 |
$result .= $rowText.$format->description.$endRow; |
| 750 |
} |
| 751 |
} elseif (in_array($format->tag->format, ['COL_LEFT', 'COL_RIGHT'])) { |
| 752 |
if (!empty($format->description)) { |
| 753 |
$result .= $rowText.$format->description.$endRow; |
| 754 |
} |
| 755 |
|
| 756 |
if ($format->tag->format === 'COL_RIGHT') { |
| 757 |
$result .= '</td><td valign="middle" style="vertical-align: middle; padding-left: 7px; '.$maxWidth.'" class="acyrightcol">'.$image; |
| 758 |
} |
| 759 |
$result .= '</td></tr></table>'; |
| 760 |
} |
| 761 |
|
| 762 |
if (!empty($format->customFields)) { |
| 763 |
$result .= '<table style="width:100%;" class="customfieldsarea"><tr>'; |
| 764 |
|
| 765 |
$format->cols = empty($format->tag->nbcols) ? 1 : intval($format->tag->nbcols); |
| 766 |
if (empty($format->cols)) $format->cols = 1; |
| 767 |
|
| 768 |
$i = 0; |
| 769 |
foreach ($format->customFields as $oneField) { |
| 770 |
if ($i != 0 && $i % $format->cols == 0) $result .= '</tr><tr>'; |
| 771 |
|
| 772 |
$result .= '<td nowrap="nowrap" class="cf'; |
| 773 |
|
| 774 |
if (empty($oneField[1])) { |
| 775 |
$result .= 'value" colspan="2">'; |
| 776 |
} else { |
| 777 |
$result .= 'label">'.$oneField[1].'</td><td class="cfvalue">'; |
| 778 |
} |
| 779 |
|
| 780 |
$result .= $oneField[0].'</td>'; |
| 781 |
$i++; |
| 782 |
} |
| 783 |
|
| 784 |
while ($i % $format->cols != 0) { |
| 785 |
$result .= '<td colspan="2"></td>'; |
| 786 |
$i++; |
| 787 |
} |
| 788 |
|
| 789 |
$result .= '</tr></table>'; |
| 790 |
} |
| 791 |
|
| 792 |
if (!empty($format->afterArticle)) { |
| 793 |
$result .= $format->afterArticle; |
| 794 |
} |
| 795 |
|
| 796 |
return $result; |
| 797 |
} |
| 798 |
|
| 799 |
public function managePicts($tag, $result) |
| 800 |
{ |
| 801 |
if (!isset($tag->pict)) { |
| 802 |
return $result; |
| 803 |
} |
| 804 |
|
| 805 |
$imageHelper = new ImageHelper(); |
| 806 |
if ($tag->pict === 'resized') { |
| 807 |
$imageHelper->maxHeight = empty($tag->maxheight) ? 150 : $tag->maxheight; |
| 808 |
$imageHelper->maxWidth = empty($tag->maxwidth) ? 150 : $tag->maxwidth; |
| 809 |
if ($imageHelper->available()) { |
| 810 |
$result = $imageHelper->resizePictures($result); |
| 811 |
} elseif (acym_isAdmin()) { |
| 812 |
acym_enqueueMessage($imageHelper->error, 'notice'); |
| 813 |
} |
| 814 |
} elseif ($tag->pict == '0') { |
| 815 |
$result = $imageHelper->removePictures($result); |
| 816 |
} |
| 817 |
|
| 818 |
return acym_absoluteURL($result); |
| 819 |
} |
| 820 |
|
| 821 |
public function displayOptions(array $options, string $dynamicIdentifier, string $type = 'individual', $defaultValues = null): string |
| 822 |
{ |
| 823 |
$suffix = preg_replace('[^a-zA-Z0-9]', '_', $dynamicIdentifier); |
| 824 |
$updateFunction = 'updateDynamic'.$suffix; |
| 825 |
|
| 826 |
$outputStructure = [ |
| 827 |
'topOptions' => [], |
| 828 |
'options' => [], |
| 829 |
]; |
| 830 |
$jsOptionsMerge = []; |
| 831 |
|
| 832 |
foreach ($options as $option) { |
| 833 |
$currentLabel = $option['title']; |
| 834 |
$currentOption = ''; |
| 835 |
|
| 836 |
if (isset($defaultValues->{$option['name']})) { |
| 837 |
$option['default'] = $defaultValues->{$option['name']}; |
| 838 |
} |
| 839 |
|
| 840 |
if ($option['type'] === 'pictures') { |
| 841 |
$displayedPictures = $option['default'] ?? 'resized'; |
| 842 |
if (isset($defaultValues->pict)) $displayedPictures = $defaultValues->pict; |
| 843 |
$resizeDisplay = 'resized' === $displayedPictures ? '' : 'style="display: none;"'; |
| 844 |
$maxWidth = $defaultValues->maxwidth ?? 150; |
| 845 |
$maxHeight = $defaultValues->maxheight ?? 150; |
| 846 |
|
| 847 |
$valImages = []; |
| 848 |
$valImages[] = acym_selectOption('1', 'ACYM_YES'); |
| 849 |
$valImages[] = acym_selectOption('resized', 'ACYM_RESIZED'); |
| 850 |
$valImages[] = acym_selectOption('0', 'ACYM_NO'); |
| 851 |
$currentOption .= '<div class="cell large-5 acym_plugin_field">'.acym_translation('ACYM_DISPLAY').'</div>'; |
| 852 |
$currentOption .= '<div class="cell large-7">'.acym_radio( |
| 853 |
$valImages, |
| 854 |
'pict'.$suffix, |
| 855 |
$displayedPictures, |
| 856 |
['onclick' => $updateFunction.'();'], |
| 857 |
['containerClass' => 'dcontent_pictures'], |
| 858 |
!acym_isAdmin() |
| 859 |
).'</div>'; |
| 860 |
$currentOption .= '<div id="pictsize'.$suffix.'" class="cell grid-x margin-y margin-top-1" '.$resizeDisplay.'> |
| 861 |
<div class="cell large-5 acym_plugin_field">'.acym_translation('ACYM_MAX_WIDTH').'</div> |
| 862 |
<div class="cell large-7"> |
| 863 |
<input class="intext_input" name="pictwidth'.$suffix.'" type="number" onchange="'.$updateFunction.'();" value="'.intval($maxWidth).'"/> |
| 864 |
</div> |
| 865 |
<div class="cell large-5 acym_plugin_field">'.acym_translation('ACYM_MAX_HEIGHT').'</div> |
| 866 |
<div class="cell large-7"> |
| 867 |
<input class="intext_input" name="pictheight'.$suffix.'" type="number" onchange="'.$updateFunction.'();" value="'.intval($maxHeight).'"/> |
| 868 |
</div> |
| 869 |
</div>'; |
| 870 |
if (!empty($option['caption'])) { |
| 871 |
$currentOption .= '<div class="cell grid-x margin-top-1">'; |
| 872 |
$currentOption .= '<label class="cell large-5 acym_plugin_field">'.acym_translation('ACYM_CAPTION').'</label>'; |
| 873 |
$currentOption .= acym_radio( |
| 874 |
[ |
| 875 |
acym_selectOption('1', 'ACYM_YES'), |
| 876 |
acym_selectOption('0', 'ACYM_NO'), |
| 877 |
], |
| 878 |
'caption'.$suffix, |
| 879 |
$defaultValues->caption ?? '0', |
| 880 |
['onclick' => $updateFunction.'();'], |
| 881 |
['containerClass' => 'cell large-7'] |
| 882 |
); |
| 883 |
$currentOption .= '</div>'; |
| 884 |
|
| 885 |
$jsOptionsMerge[] = 'otherinfo += "| caption:" + jQuery(\'input[name="caption'.$suffix.'"]:checked\').val();'; |
| 886 |
} |
| 887 |
|
| 888 |
$jsOptionsMerge[] = ' |
| 889 |
var _pictVal'.$suffix.' = jQuery(\'input[name="pict'.$suffix.'"]:checked\').val(); |
| 890 |
otherinfo += "| pict:" + _pictVal'.$suffix.'; |
| 891 |
|
| 892 |
if(_pictVal'.$suffix.' == "resized"){ |
| 893 |
jQuery("#pictsize'.$suffix.'").show(); |
| 894 |
otherinfo += "| maxwidth:" + jQuery(\'input[name="pictwidth'.$suffix.'"]\').val(); |
| 895 |
otherinfo += "| maxheight:" + jQuery(\'input[name="pictheight'.$suffix.'"]\').val(); |
| 896 |
}else{ |
| 897 |
jQuery("#pictsize'.$suffix.'").hide(); |
| 898 |
}'; |
| 899 |
} elseif ($option['type'] === 'checkbox') { |
| 900 |
if (!empty($option['default'])) { |
| 901 |
$checkedValues = explode(',', $option['default']); |
| 902 |
foreach ($option['options'] as $key => $oneOption) { |
| 903 |
$oneOption[1] = in_array($key, $checkedValues); |
| 904 |
$option['options'][$key] = $oneOption; |
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
$currentOption .= '<div class="cell grid-x">'; |
| 909 |
foreach ($option['options'] as $value => $title) { |
| 910 |
$currentOption .= '<div class="cell medium-6" '.(empty($title[2]) ? '' : $title[2]).'> |
| 911 |
<input type="checkbox" name="'.acym_escape($option['name'].$suffix).'" value="'.acym_escape($value).'" id="'.acym_escape( |
| 912 |
$value.$suffix |
| 913 |
).'" onclick="'.$updateFunction.'();" '.($title[1] ? 'checked="checked"' : '').'/> |
| 914 |
<label style="margin-left:5px" for="'.acym_escape($value.$suffix).'">'.acym_translation($title[0]).'</label> |
| 915 |
</div>'; |
| 916 |
} |
| 917 |
$currentOption .= '</div>'; |
| 918 |
|
| 919 |
if (empty($option['separator'])) $option['separator'] = ','; |
| 920 |
|
| 921 |
$jsOptionsMerge[] = 'var _checked'.$option['name'].$suffix.' = []; |
| 922 |
jQuery("input:checkbox[name='.$option['name'].$suffix.']:checked").each(function(){ |
| 923 |
_checked'.$option['name'].$suffix.'.push(jQuery(this).val()); |
| 924 |
}); |
| 925 |
if(_checked'.$option['name'].$suffix.'.length) otherinfo += "| '.$option['name'].':" + _checked'.$option['name'].$suffix.'.join("'.$option['separator'].'");'; |
| 926 |
} elseif ($option['type'] === 'boolean') { |
| 927 |
if ($option['name'] === 'autologin' && $this->config->get('autologin_urls', 0) != 1) { |
| 928 |
continue; |
| 929 |
} |
| 930 |
|
| 931 |
$currentOption .= acym_boolean( |
| 932 |
$option['name'].$suffix, |
| 933 |
$option['default'], |
| 934 |
$option['name'].$suffix, |
| 935 |
['onclick' => $updateFunction.'();'] |
| 936 |
); |
| 937 |
|
| 938 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]:checked\').val();'; |
| 939 |
} elseif ($option['type'] === 'radio') { |
| 940 |
$radioOptions = []; |
| 941 |
foreach ($option['options'] as $value => $title) { |
| 942 |
$radioOptions[] = acym_selectOption($value, $title); |
| 943 |
} |
| 944 |
|
| 945 |
$currentOption .= acym_radio( |
| 946 |
$radioOptions, |
| 947 |
$option['name'].$suffix, |
| 948 |
$option['default'], |
| 949 |
['onclick' => $updateFunction.'();'], |
| 950 |
['pluginMode' => true], |
| 951 |
!acym_isAdmin() |
| 952 |
); |
| 953 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]:checked\').val();'; |
| 954 |
} elseif ($option['type'] === 'select') { |
| 955 |
$selectOptions = []; |
| 956 |
foreach ($option['options'] as $value => $title) { |
| 957 |
if (is_object($title)) { |
| 958 |
$selectOptions[] = acym_selectOption($title->value, $title->text); |
| 959 |
} else { |
| 960 |
$selectOptions[] = acym_selectOption($value, $title); |
| 961 |
} |
| 962 |
} |
| 963 |
|
| 964 |
$default = empty($option['default']) ? null : $option['default']; |
| 965 |
if (!empty($default) && strpos($default, ',')) [$default, $defaultOrder] = explode(',', $default); |
| 966 |
|
| 967 |
$attributes = [ |
| 968 |
'onchange' => $updateFunction.'();', |
| 969 |
'id' => $option['name'].$suffix, |
| 970 |
]; |
| 971 |
if ($option['name'] === 'order') { |
| 972 |
$attributes['class'] = 'acym__dynamics__ordering__select'; |
| 973 |
} |
| 974 |
$currentOption .= acym_select( |
| 975 |
$selectOptions, |
| 976 |
$option['name'].$suffix, |
| 977 |
$default, |
| 978 |
$attributes |
| 979 |
); |
| 980 |
|
| 981 |
if ($option['name'] === 'order') { |
| 982 |
$dirs = [ |
| 983 |
'desc' => acym_translation('ACYM_DESC'), |
| 984 |
'asc' => acym_translation('ACYM_ASC'), |
| 985 |
]; |
| 986 |
if (empty($defaultOrder)) $defaultOrder = empty($option['defaultdir']) ? null : $option['defaultdir']; |
| 987 |
$currentOption .= ' '.acym_select( |
| 988 |
$dirs, |
| 989 |
'orderdir'.$suffix, |
| 990 |
$defaultOrder, |
| 991 |
[ |
| 992 |
'onchange' => $updateFunction.'();', |
| 993 |
'style' => 'width: 115px;', |
| 994 |
'class' => 'acym__dynamics__ordering__select', |
| 995 |
] |
| 996 |
); |
| 997 |
|
| 998 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val() + "," + jQuery(\'[name="orderdir'.$suffix.'"]\').val();'; |
| 999 |
} else { |
| 1000 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1001 |
} |
| 1002 |
} elseif ($option['type'] === 'multiselect') { |
| 1003 |
$selectOptions = []; |
| 1004 |
foreach ($option['options'] as $value => $title) { |
| 1005 |
$selectOptions[] = acym_selectOption($value, $title); |
| 1006 |
} |
| 1007 |
|
| 1008 |
|
| 1009 |
if (!isset($option['default'])) $option['default'] = []; |
| 1010 |
if (!is_array($option['default'])) $option['default'] = explode(',', $option['default']); |
| 1011 |
|
| 1012 |
$currentOption .= acym_selectMultiple( |
| 1013 |
$selectOptions, |
| 1014 |
$option['name'].$suffix, |
| 1015 |
$option['default'], |
| 1016 |
['onchange' => $updateFunction.'();', 'id' => $option['name'].$suffix] |
| 1017 |
); |
| 1018 |
|
| 1019 |
$jsOptionsMerge[] = ' |
| 1020 |
var theMultiSelect = document.querySelector(\'[name="'.$option['name'].$suffix.'[]"]\'); |
| 1021 |
var selectedOptions = []; |
| 1022 |
for(var i = 0 ; i < theMultiSelect.length ; i++){ |
| 1023 |
if(theMultiSelect[i].selected){ |
| 1024 |
selectedOptions.push(theMultiSelect[i].value); |
| 1025 |
} |
| 1026 |
} |
| 1027 |
otherinfo += "| '.$option['name'].':" + selectedOptions.join(",");'; |
| 1028 |
} elseif ($option['type'] === 'text') { |
| 1029 |
if (!isset($option['default'])) $option['default'] = ''; |
| 1030 |
$class = empty($option['class']) ? 'acym_plugin_text_field' : $option['class']; |
| 1031 |
$placeholder = empty($option['placeholder']) ? '' : ' placeholder="'.acym_escape($option['placeholder']).'"'; |
| 1032 |
$currentOption .= '<input |
| 1033 |
type="text" |
| 1034 |
name="'.$option['name'].$suffix.'" |
| 1035 |
id="'.$option['name'].$suffix.'" |
| 1036 |
onchange="'.$updateFunction.'();" |
| 1037 |
value="'.acym_escape($option['default']).'" |
| 1038 |
class="'.acym_escape($class).'" '.$placeholder.'/>'; |
| 1039 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1040 |
} elseif ($option['type'] === 'number') { |
| 1041 |
$min = empty($option['min']) ? ' min="0"' : ' min="'.$option['min'].'"'; |
| 1042 |
$max = empty($option['max']) ? '' : ' max="'.$option['max'].'"'; |
| 1043 |
$class = empty($option['class']) ? 'acym_plugin_text_field' : $option['class']; |
| 1044 |
$currentOption .= '<input type="number"'.$min.$max.' name="'.$option['name'].$suffix.'" id="'.$option['name'].$suffix.'" onchange="'.$updateFunction.'();" value="'.intval( |
| 1045 |
$option['default'] |
| 1046 |
).'" class="'.acym_escape($class).'" />'; |
| 1047 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1048 |
} elseif ($option['type'] === 'intextfield') { |
| 1049 |
$inputType = 'text'; |
| 1050 |
if (!empty($option['isNumber']) && $option['isNumber'] === 1) $inputType = 'number'; |
| 1051 |
$currentOption .= acym_translationSprintf( |
| 1052 |
$option['text'], |
| 1053 |
'<input type="'.$inputType.'" name="'.$option['name'].$suffix.'" id="'.$option['name'].$suffix.'" class="intext_input" value="'.acym_escape( |
| 1054 |
$option['default'] |
| 1055 |
).'" onchange="'.$updateFunction.'();"/>' |
| 1056 |
); |
| 1057 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1058 |
} elseif ($option['type'] === 'date') { |
| 1059 |
$relativeTime = '-'; |
| 1060 |
if (!empty($option['relativeDate'])) $relativeTime = $option['relativeDate']; |
| 1061 |
if (!empty($option['default']) && !is_numeric($option['default']) && false === strpos($option['default'], '[time]')) { |
| 1062 |
$option['default'] = strtotime($option['default']); |
| 1063 |
} |
| 1064 |
$currentOption .= acym_dateField($option['name'].$suffix, $option['default'], '', ' onchange="'.$updateFunction.'();"', $relativeTime); |
| 1065 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1066 |
} elseif ($option['type'] === 'language') { |
| 1067 |
$languageOptions = []; |
| 1068 |
$languageOptions['any'] = acym_translation('ACYM_ANY'); |
| 1069 |
|
| 1070 |
$languages = acym_getLanguages(true); |
| 1071 |
foreach ($languages as $language) { |
| 1072 |
$languageOptions[$language->language] = $language->name; |
| 1073 |
} |
| 1074 |
|
| 1075 |
if (empty($option['default'])) { |
| 1076 |
$option['default'] = acym_getVar('string', 'language'); |
| 1077 |
if (acym_isMultilingual() && (empty($option['default']) || $option['default'] === 'main')) { |
| 1078 |
$option['default'] = $this->config->get('multilingual_default'); |
| 1079 |
} |
| 1080 |
} |
| 1081 |
|
| 1082 |
$currentOption .= acym_select( |
| 1083 |
$languageOptions, |
| 1084 |
$option['name'].$suffix, |
| 1085 |
empty($option['default']) ? null : $option['default'], |
| 1086 |
[ |
| 1087 |
'onchange' => $updateFunction.'();', |
| 1088 |
'id' => $option['name'].$suffix, |
| 1089 |
] |
| 1090 |
); |
| 1091 |
|
| 1092 |
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val();'; |
| 1093 |
} elseif ($option['type'] == 'custom') { |
| 1094 |
$currentOption .= $option['output']; |
| 1095 |
$jsOptionsMerge[] = $option['js']; |
| 1096 |
} |
| 1097 |
|
| 1098 |
if (!empty($option['main']) || in_array($option['type'], ['pictures', 'checkbox'])) { |
| 1099 |
$outputStructure['topOptions'][$currentLabel] = $currentOption; |
| 1100 |
|
| 1101 |
if ($option['type'] === 'checkbox' && $currentLabel === 'ACYM_DISPLAY' && (!isset($option['format']) || $option['format'])) { |
| 1102 |
$formatOption = '<div class="grid-x">'; |
| 1103 |
$formatOption .= '<div class="cell large-3">'.acym_translation('ACYM_FORMAT').'</div>'; |
| 1104 |
$formatOption .= '<div class="cell large-9 dcontentFormatContainer">'; |
| 1105 |
|
| 1106 |
$default = empty($defaultValues->format) ? 'TOP_LEFT' : $defaultValues->format; |
| 1107 |
$formats = ['TOP_LEFT', 'TOP_RIGHT', 'TITLE_IMG', 'TITLE_IMG_RIGHT', 'CENTER_IMG', 'TOP_IMG', 'COL_LEFT', 'COL_RIGHT']; |
| 1108 |
foreach ($formats as $oneFormat) { |
| 1109 |
$class = 'button-radio'; |
| 1110 |
if ($default === $oneFormat) $class .= ' button-radio-selected'; |
| 1111 |
|
| 1112 |
$formatOption .= '<button |
| 1113 |
class="'.$class.'" |
| 1114 |
acym-button-radio-group="dcontentFormat'.$suffix.'" |
| 1115 |
acym-data-type="'.$oneFormat.'" |
| 1116 |
acym-callback="'.$updateFunction.'"> |
| 1117 |
<img alt="'.$oneFormat.'" src="'.ACYM_IMAGES.'editor/dcontent_formats/'.strtolower($oneFormat).'.png"/> |
| 1118 |
</button>'; |
| 1119 |
} |
| 1120 |
$formatOption .= '</div>'; |
| 1121 |
|
| 1122 |
if ($type === 'grouped') { |
| 1123 |
$formatOption .= '<div class="cell large-3">'.acym_translation('ACYM_ALTERNATE').acym_info('ACYM_ALTERNATE_DESC').'</div>'; |
| 1124 |
$formatOption .= '<div class="cell large-9">'; |
| 1125 |
$formatOption .= acym_boolean( |
| 1126 |
'alternate'.$suffix, |
| 1127 |
!empty($defaultValues->alternate), |
| 1128 |
'alternate'.$suffix, |
| 1129 |
['onclick' => $updateFunction.'();'] |
| 1130 |
); |
| 1131 |
$formatOption .= '</div>'; |
| 1132 |
|
| 1133 |
$jsOptionsMerge[] = 'var alternate = jQuery(\'input[name="alternate'.$suffix.'"]:checked\').val();'; |
| 1134 |
$jsOptionsMerge[] = 'if (!acym_helper.empty(alternate)) otherinfo += "| alternate";'; |
| 1135 |
} |
| 1136 |
|
| 1137 |
$formatOption .= '</div>'; |
| 1138 |
|
| 1139 |
$jsOptionsMerge[] = 'var selectedFormatOption = jQuery(\'.button-radio-selected[acym-button-radio-group="dcontentFormat'.$suffix.'"]\')'; |
| 1140 |
$jsOptionsMerge[] = 'if (!acym_helper.empty(selectedFormatOption)) otherinfo += "| format:" + selectedFormatOption.attr("acym-data-type");'; |
| 1141 |
|
| 1142 |
$outputStructure['topOptions']['ACYM_FORMAT'] = $formatOption; |
| 1143 |
} |
| 1144 |
continue; |
| 1145 |
} |
| 1146 |
|
| 1147 |
if (empty($option['section'])) { |
| 1148 |
$option['section'] = 'ACYM_OTHER_OPTIONS'; |
| 1149 |
} |
| 1150 |
|
| 1151 |
$currentLabel = acym_translation($currentLabel); |
| 1152 |
if (!empty($option['tooltip'])) { |
| 1153 |
$currentLabel .= ' '.acym_info($option['tooltip'], 'acym_plugin_field_'.$option['name']); |
| 1154 |
} |
| 1155 |
$currentLabel = '<label class="cell large-5 acym_plugin_field acym_plugin_field_'.$option['type'].'" for="'.acym_escape( |
| 1156 |
$option['name'].$suffix |
| 1157 |
).'">'.$currentLabel.'</label>'; |
| 1158 |
|
| 1159 |
$outputStructure['options'][$option['section']][$currentLabel] = $currentOption; |
| 1160 |
} |
| 1161 |
|
| 1162 |
if (!empty($outputStructure['options'])) { |
| 1163 |
foreach ($outputStructure['options'] as $section => $options) { |
| 1164 |
$formattedOptions = ''; |
| 1165 |
foreach ($options as $label => $option) { |
| 1166 |
$formattedOptions .= '<div class="cell grid-x margin-bottom-1">'.$label; |
| 1167 |
$formattedOptions .= '<div class="cell large-7">'.$option.'</div>'; |
| 1168 |
$formattedOptions .= '</div>'; |
| 1169 |
} |
| 1170 |
$outputStructure['topOptions'][$section] = $formattedOptions; |
| 1171 |
} |
| 1172 |
} |
| 1173 |
|
| 1174 |
$output = ''; |
| 1175 |
if (!empty($outputStructure['topOptions'])) { |
| 1176 |
foreach ($outputStructure['topOptions'] as $label => $oneOption) { |
| 1177 |
$output .= '<p class="acym__wysid__right__toolbar__p acym__wysid__right__toolbar__p__open acym__title">'; |
| 1178 |
$output .= acym_translation($label).'<i class="acymicon-keyboard-arrow-up"></i>'; |
| 1179 |
$output .= '</p>'; |
| 1180 |
$output .= '<div class="acym__wysid__right__toolbar__design--show acym__wysid__right__toolbar__design acym__wysid__context__modal__container grid-x">'; |
| 1181 |
$output .= $oneOption; |
| 1182 |
$output .= '</div>'; |
| 1183 |
} |
| 1184 |
} |
| 1185 |
|
| 1186 |
$output .= ' |
| 1187 |
<script type="text/javascript"> |
| 1188 |
var _selectedRows'.$suffix.' = []; |
| 1189 |
var _selectedRows = []; |
| 1190 |
if("undefined" === typeof _additionalInfo'.$suffix.') { |
| 1191 |
var _additionalInfo'.$suffix.' = {}; |
| 1192 |
} |
| 1193 |
'; |
| 1194 |
if (!empty($defaultValues->id) && (empty($defaultValues->defaultPluginTab) || $dynamicIdentifier === $defaultValues->defaultPluginTab)) { |
| 1195 |
$delimiter = strpos($defaultValues->id, '-') ? '-' : ','; |
| 1196 |
$selected = explode($delimiter, $defaultValues->id); |
| 1197 |
|
| 1198 |
foreach ($selected as $value) { |
| 1199 |
if (empty($value)) continue; |
| 1200 |
$output .= '_selectedRows'.$suffix.'['.intval($value).'] = true; |
| 1201 |
'; |
| 1202 |
} |
| 1203 |
} |
| 1204 |
|
| 1205 |
$output .= ' |
| 1206 |
function applyContent'.$suffix.'(contentid, row){ |
| 1207 |
if(_selectedRows'.$suffix.'[contentid]){ |
| 1208 |
jQuery(row).removeClass("selected_row"); |
| 1209 |
delete _selectedRows'.$suffix.'[contentid]; |
| 1210 |
}else{ |
| 1211 |
'; |
| 1212 |
|
| 1213 |
if ('individual' === $type) { |
| 1214 |
$output .= ' |
| 1215 |
for(let elementKey in _selectedRows'.$suffix.') { |
| 1216 |
if(!_selectedRows'.$suffix.'.hasOwnProperty(elementKey)) continue; |
| 1217 |
|
| 1218 |
jQuery(\'[data-id="\' + elementKey + \'"]\').removeClass("selected_row"); |
| 1219 |
delete _selectedRows'.$suffix.'[elementKey]; |
| 1220 |
} |
| 1221 |
'; |
| 1222 |
} |
| 1223 |
|
| 1224 |
$output .= ' |
| 1225 |
jQuery(row).addClass("selected_row"); |
| 1226 |
_selectedRows'.$suffix.'[contentid] = true; |
| 1227 |
} |
| 1228 |
'.$updateFunction.'(); |
| 1229 |
|
| 1230 |
if(typeof _selectedRows !== "undefined"){ |
| 1231 |
_selectedRows = _selectedRows'.$suffix.'; |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
function '.$updateFunction.'(){ |
| 1236 |
var tag = ""; |
| 1237 |
var otherinfo = ""; |
| 1238 |
|
| 1239 |
'.implode("\r\n\r\n", $jsOptionsMerge).' |
| 1240 |
|
| 1241 |
for (let [index, info] of Object.entries(_additionalInfo'.$suffix.')){ |
| 1242 |
otherinfo += "| "+index+":"+info; |
| 1243 |
} |
| 1244 |
'; |
| 1245 |
|
| 1246 |
if ($type == 'individual') { |
| 1247 |
$output .= ' |
| 1248 |
for(var i in _selectedRows'.$suffix.'){ |
| 1249 |
if(!_selectedRows'.$suffix.'.hasOwnProperty(i)) continue; |
| 1250 |
|
| 1251 |
tag = tag + "{'.$dynamicIdentifier.':" + i + otherinfo + "}"; |
| 1252 |
}'; |
| 1253 |
} elseif ($type == 'grouped') { |
| 1254 |
$output .= ' |
| 1255 |
tag = "{'.$dynamicIdentifier.':"; |
| 1256 |
for(var icat in _selectedRows'.$suffix.'){ |
| 1257 |
if(!_selectedRows'.$suffix.'.hasOwnProperty(icat)) continue; |
| 1258 |
tag += icat + "-"; |
| 1259 |
} |
| 1260 |
tag += otherinfo + "}";'; |
| 1261 |
} elseif ($type == 'simple') { |
| 1262 |
$output .= ' |
| 1263 |
tag = "{'.$dynamicIdentifier.':" + otherinfo + "}";'; |
| 1264 |
} |
| 1265 |
|
| 1266 |
$output .= ' |
| 1267 |
acym_editorWysidDynamic.insertDContent(tag); |
| 1268 |
} |
| 1269 |
|
| 1270 |
function addAdditionalInfo'.$suffix.'(index, value){ |
| 1271 |
_additionalInfo'.$suffix.'[index] = value; |
| 1272 |
'.$updateFunction.'(); |
| 1273 |
} |
| 1274 |
</script>'; |
| 1275 |
|
| 1276 |
if ($type == 'individual') { |
| 1277 |
acym_trigger('displayCustomViewEditor', [&$output], 'plgAcym'.ucfirst($dynamicIdentifier)); |
| 1278 |
$output .= '<input type="hidden" id="acym__dynamic__update__function" value="'.$updateFunction.'">'; |
| 1279 |
} |
| 1280 |
|
| 1281 |
return $output; |
| 1282 |
} |
| 1283 |
|
| 1284 |
public function translateItem(object &$item, object &$tag, string $referenceTable, int $referenceId = 0): void |
| 1285 |
{ |
| 1286 |
if (!acym_isExtensionActive('com_falang')) { |
| 1287 |
return; |
| 1288 |
} |
| 1289 |
|
| 1290 |
if (!empty($tag->falang)) { |
| 1291 |
$langId = $tag->falang; |
| 1292 |
} elseif (!empty($tag->lang)) { |
| 1293 |
$langId = intval(substr($tag->lang, strpos($tag->lang, ',') + 1)); |
| 1294 |
} elseif (!empty($this->contextLanguage)) { |
| 1295 |
$languages = acym_loadObjectList('SELECT `lang_id`, `lang_code` FROM #__languages', 'lang_code'); |
| 1296 |
if (!empty($languages[$this->contextLanguage])) { |
| 1297 |
$langId = $languages[$this->contextLanguage]->lang_id; |
| 1298 |
} |
| 1299 |
} |
| 1300 |
|
| 1301 |
if (empty($langId)) { |
| 1302 |
return; |
| 1303 |
} |
| 1304 |
|
| 1305 |
if (empty($referenceId)) { |
| 1306 |
$referenceId = $tag->id; |
| 1307 |
} |
| 1308 |
|
| 1309 |
$translations = acym_loadObjectList( |
| 1310 |
'SELECT `reference_field`, `value` |
| 1311 |
FROM `#__falang_content` |
| 1312 |
WHERE `published` = 1 |
| 1313 |
AND `reference_table` = '.acym_escapeDB($referenceTable).' |
| 1314 |
AND `language_id` = '.intval($langId).' |
| 1315 |
AND `reference_id` = '.intval($referenceId) |
| 1316 |
); |
| 1317 |
|
| 1318 |
if (empty($translations)) { |
| 1319 |
return; |
| 1320 |
} |
| 1321 |
|
| 1322 |
foreach ($translations as $oneTranslation) { |
| 1323 |
if (empty($oneTranslation->value)) { |
| 1324 |
continue; |
| 1325 |
} |
| 1326 |
|
| 1327 |
$translatedField = $oneTranslation->reference_field; |
| 1328 |
$item->$translatedField = $oneTranslation->value; |
| 1329 |
} |
| 1330 |
} |
| 1331 |
|
| 1332 |
public function createDummyEmailObject(int $mailId, string $code, string $previewBody) |
| 1333 |
{ |
| 1334 |
if (!empty($mailId)) { |
| 1335 |
$mailClass = new MailClass(); |
| 1336 |
$email = $mailClass->getOneById($mailId); |
| 1337 |
} |
| 1338 |
|
| 1339 |
if (empty($email)) { |
| 1340 |
$email = new \stdClass(); |
| 1341 |
$email->id = 0; |
| 1342 |
$email->name = ''; |
| 1343 |
$email->subject = ''; |
| 1344 |
$email->from_name = ''; |
| 1345 |
$email->from_email = ''; |
| 1346 |
$email->reply_to_name = ''; |
| 1347 |
$email->reply_to_email = ''; |
| 1348 |
$email->bcc = ''; |
| 1349 |
$email->links_language = ''; |
| 1350 |
} |
| 1351 |
|
| 1352 |
$language = acym_getVar('string', 'language', 'main'); |
| 1353 |
if (!empty($language)) { |
| 1354 |
if ($language === 'main') { |
| 1355 |
$language = $this->config->get('multilingual_default', ACYM_DEFAULT_LANGUAGE); |
| 1356 |
} |
| 1357 |
$email->links_language = $language; |
| 1358 |
} |
| 1359 |
|
| 1360 |
$email->creation_date = acym_date('now', 'Y-m-d H:i:s', false); |
| 1361 |
$email->creator_id = acym_currentUserId(); |
| 1362 |
$email->thumbnail = ''; |
| 1363 |
$email->drag_editor = '1'; |
| 1364 |
$email->type = MailClass::TYPE_STANDARD; |
| 1365 |
$email->settings = ''; |
| 1366 |
$email->stylesheet = ''; |
| 1367 |
$email->attachments = ''; |
| 1368 |
|
| 1369 |
$email->body = $code; |
| 1370 |
$email->previewBody = $previewBody; |
| 1371 |
|
| 1372 |
return $email; |
| 1373 |
} |
| 1374 |
} |
| 1375 |
|