'."\n"; $beforeAll['ul'] = '
',
$text
);
$text = preg_replace(
'##i',
'
',
$text
);
$text = preg_replace(
'#{JoooidContent[^}]*youtube[^}]*id"[^"]*"([^}"]*)"[^}]*}#i',
'
',
$text
);
$text = preg_replace(
'##Uis',
'
',
$text
);
$text = preg_replace(
'#{youtube}[^{]+v=([^{&]+)(&[^{]*)?{/youtube}#Uis',
'
',
$text
);
$text = preg_replace('#{vimeo}(https://vimeo.com/[^{]+){/vimeo}#Uis', '', $text);
$text = preg_replace('#{vimeo}([^{]+){/vimeo}#Uis', '', $text);
if (preg_match_all('##Uis', $text, $matches)) {
foreach ($matches[1] as $key => $match) {
$hash = acym_fileGetContent('https://vimeo.com/api/v2/video/'.$match.'.php');
$hash = @unserialize($hash);
if (empty($hash)) continue;
if (strpos($matches[0][$key], ' width="') !== false) {
$extension = substr($hash[0]['thumbnail_large'], strrpos($hash[0]['thumbnail_large'], '.'));
preg_match('#width="([^"]*)"#Uis', $matches[0][$key], $width);
$replace = strpos($hash[0]['thumbnail_large'], '_') === false ? '.' : '_';
$hash[0]['thumbnail_large'] = substr($hash[0]['thumbnail_large'], 0, strrpos($hash[0]['thumbnail_large'], $replace)).'_'.$width[1].$extension;
}
$thumbnail = 'https://i.vimeocdn.com/filter/overlay?src='.urlencode($hash[0]['thumbnail_large']);
$thumbnail .= '&src='.urlencode('https://f.vimeocdn.com/p/images/crawler_play.png');
$text = str_replace(
$matches[0][$key],
'
', $text);
$text = preg_replace('##i', '
', $text);
}
private function convertbase64pictures(string &$html): void
{
if (!preg_match_all('#]*>)#Uis'] = '$1'; $newbody = preg_replace(array_keys($pregreplace), $pregreplace, $html); if (!empty($newbody)) { $html = $newbody; } $body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', [$this, 'convertSpaces'], $html); if (!empty($body)) $html = $body; $html = acym_cmsCleanHtml($html); } public function convertSpaces(array $matches): string { return "src='".str_replace(' ', '%20', $matches[1])."'"; } public function replaceTags(object &$email, array $tags, bool $html = false): void { if (empty($tags)) return; $htmlVars = ['body']; $textVars = [ 'subject', 'AltBody', 'From', 'FromName', 'ReplyTo', 'ReplyName', 'bcc', 'cc', 'fromname', 'fromemail', 'replyname', 'replyemail', 'params', 'preheader', ]; $variables = array_merge($htmlVars, $textVars); if ($html) { if (empty($this->mailerHelper)) { $this->mailerHelper = new MailerHelper(); } $textreplace = []; foreach ($tags as $i => $replacement) { if (isset($textreplace[$i])) continue; $textreplace[$i] = $this->mailerHelper->textVersion($replacement); } } else { $textreplace = $tags; } foreach ($variables as $var) { if (empty($email->$var)) continue; $email->$var = $this->replaceDText($email->$var, in_array($var, $htmlVars) ? $tags : $textreplace); } } public function replaceDText($text, $replacement) { if (is_array($text)) { foreach ($text as &$oneCell) { if (empty($oneCell)) continue; $oneCell = $this->replaceDText($oneCell, $replacement); } } elseif (is_string($text) && !empty($text)) { foreach ($replacement as $code => $value) { $codes = [$code, urlencode($code)]; if (is_null($value)) { $value = ''; } $safePregValue = str_replace('$', '\$', $value); foreach ($codes as $oneCode) { $text = preg_replace( '#]+'.preg_quote($oneCode, '#').'.+[^<]*#Uis', $safePregValue, $text ); $text = preg_replace( '#(
'.acym_escape($format->imageCaption).'
'; } } $result = ''; if (in_array($format->tag->format, ['TITLE_IMG', 'TITLE_IMG_RIGHT'])) { $format->title = $image.$format->title; $image = ''; } if (!empty($format->link) && !empty($image) && !empty($format->tag->clickableimg)) { $image = ''.$image.''; } if ($format->tag->format === 'TOP_IMG' && !empty($image)) { $result = $image; $image = ''; } if (in_array($format->tag->format, ['COL_LEFT', 'COL_RIGHT'])) { $maxWidth = empty($format->tag->maxwidth) ? '' : ' width: '.$format->tag->maxwidth.'px;'; if (empty($image)) { $format->tag->format = 'TOP_LEFT'; } else { $result = '';
if ($format->tag->format === 'COL_LEFT') {
$result = '
'.acym_translation('ACYM_DISPLAY').' ';
$currentOption .= ''.acym_radio(
$valImages,
'pict'.$suffix,
$displayedPictures,
['onclick' => $updateFunction.'();'],
['containerClass' => 'dcontent_pictures'],
!acym_isAdmin()
).' ';
$currentOption .= ''.acym_translation('ACYM_MAX_WIDTH').'
'.acym_translation('ACYM_MAX_HEIGHT').'
';
$currentOption .= '';
$currentOption .= acym_radio(
[
acym_selectOption('1', 'ACYM_YES'),
acym_selectOption('0', 'ACYM_NO'),
],
'caption'.$suffix,
$defaultValues->caption ?? '0',
['onclick' => $updateFunction.'();'],
['containerClass' => 'cell large-7']
);
$currentOption .= ' ';
$jsOptionsMerge[] = 'otherinfo += "| caption:" + jQuery(\'input[name="caption'.$suffix.'"]:checked\').val();';
}
$jsOptionsMerge[] = '
var _pictVal'.$suffix.' = jQuery(\'input[name="pict'.$suffix.'"]:checked\').val();
otherinfo += "| pict:" + _pictVal'.$suffix.';
if(_pictVal'.$suffix.' == "resized"){
jQuery("#pictsize'.$suffix.'").show();
otherinfo += "| maxwidth:" + jQuery(\'input[name="pictwidth'.$suffix.'"]\').val();
otherinfo += "| maxheight:" + jQuery(\'input[name="pictheight'.$suffix.'"]\').val();
}else{
jQuery("#pictsize'.$suffix.'").hide();
}';
} elseif ($option['type'] === 'checkbox') {
if (!empty($option['default'])) {
$checkedValues = explode(',', $option['default']);
foreach ($option['options'] as $key => $oneOption) {
$oneOption[1] = in_array($key, $checkedValues);
$option['options'][$key] = $oneOption;
}
}
$currentOption .= '';
foreach ($option['options'] as $value => $title) {
$currentOption .= ' ';
if (empty($option['separator'])) $option['separator'] = ',';
$jsOptionsMerge[] = 'var _checked'.$option['name'].$suffix.' = [];
jQuery("input:checkbox[name='.$option['name'].$suffix.']:checked").each(function(){
_checked'.$option['name'].$suffix.'.push(jQuery(this).val());
});
if(_checked'.$option['name'].$suffix.'.length) otherinfo += "| '.$option['name'].':" + _checked'.$option['name'].$suffix.'.join("'.$option['separator'].'");';
} elseif ($option['type'] === 'boolean') {
if ($option['name'] === 'autologin' && $this->config->get('autologin_urls', 0) != 1) {
continue;
}
$currentOption .= acym_boolean(
$option['name'].$suffix,
$option['default'],
$option['name'].$suffix,
['onclick' => $updateFunction.'();']
);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]:checked\').val();';
} elseif ($option['type'] === 'radio') {
$radioOptions = [];
foreach ($option['options'] as $value => $title) {
$radioOptions[] = acym_selectOption($value, $title);
}
$currentOption .= acym_radio(
$radioOptions,
$option['name'].$suffix,
$option['default'],
['onclick' => $updateFunction.'();'],
['pluginMode' => true],
!acym_isAdmin()
);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]:checked\').val();';
} elseif ($option['type'] === 'select') {
$selectOptions = [];
foreach ($option['options'] as $value => $title) {
if (is_object($title)) {
$selectOptions[] = acym_selectOption($title->value, $title->text);
} else {
$selectOptions[] = acym_selectOption($value, $title);
}
}
$default = empty($option['default']) ? null : $option['default'];
if (!empty($default) && strpos($default, ',')) [$default, $defaultOrder] = explode(',', $default);
$attributes = [
'onchange' => $updateFunction.'();',
'id' => $option['name'].$suffix,
];
if ($option['name'] === 'order') {
$attributes['class'] = 'acym__dynamics__ordering__select';
}
$currentOption .= acym_select(
$selectOptions,
$option['name'].$suffix,
$default,
$attributes
);
if ($option['name'] === 'order') {
$dirs = [
'desc' => acym_translation('ACYM_DESC'),
'asc' => acym_translation('ACYM_ASC'),
];
if (empty($defaultOrder)) $defaultOrder = empty($option['defaultdir']) ? null : $option['defaultdir'];
$currentOption .= ' '.acym_select(
$dirs,
'orderdir'.$suffix,
$defaultOrder,
[
'onchange' => $updateFunction.'();',
'style' => 'width: 115px;',
'class' => 'acym__dynamics__ordering__select',
]
);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val() + "," + jQuery(\'[name="orderdir'.$suffix.'"]\').val();';
} else {
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val();';
}
} elseif ($option['type'] === 'multiselect') {
$selectOptions = [];
foreach ($option['options'] as $value => $title) {
$selectOptions[] = acym_selectOption($value, $title);
}
if (!isset($option['default'])) $option['default'] = [];
if (!is_array($option['default'])) $option['default'] = explode(',', $option['default']);
$currentOption .= acym_selectMultiple(
$selectOptions,
$option['name'].$suffix,
$option['default'],
['onchange' => $updateFunction.'();', 'id' => $option['name'].$suffix]
);
$jsOptionsMerge[] = '
var theMultiSelect = document.querySelector(\'[name="'.$option['name'].$suffix.'[]"]\');
var selectedOptions = [];
for(var i = 0 ; i < theMultiSelect.length ; i++){
if(theMultiSelect[i].selected){
selectedOptions.push(theMultiSelect[i].value);
}
}
otherinfo += "| '.$option['name'].':" + selectedOptions.join(",");';
} elseif ($option['type'] === 'text') {
if (!isset($option['default'])) $option['default'] = '';
$class = empty($option['class']) ? 'acym_plugin_text_field' : $option['class'];
$placeholder = empty($option['placeholder']) ? '' : ' placeholder="'.acym_escape($option['placeholder']).'"';
$currentOption .= '';
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();';
} elseif ($option['type'] === 'number') {
$min = empty($option['min']) ? ' min="0"' : ' min="'.$option['min'].'"';
$max = empty($option['max']) ? '' : ' max="'.$option['max'].'"';
$class = empty($option['class']) ? 'acym_plugin_text_field' : $option['class'];
$currentOption .= '';
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();';
} elseif ($option['type'] === 'intextfield') {
$inputType = 'text';
if (!empty($option['isNumber']) && $option['isNumber'] === 1) $inputType = 'number';
$currentOption .= acym_translationSprintf(
$option['text'],
''
);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();';
} elseif ($option['type'] === 'date') {
$relativeTime = '-';
if (!empty($option['relativeDate'])) $relativeTime = $option['relativeDate'];
if (!empty($option['default']) && !is_numeric($option['default']) && false === strpos($option['default'], '[time]')) {
$option['default'] = strtotime($option['default']);
}
$currentOption .= acym_dateField($option['name'].$suffix, $option['default'], '', ' onchange="'.$updateFunction.'();"', $relativeTime);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'input[name="'.$option['name'].$suffix.'"]\').val();';
} elseif ($option['type'] === 'language') {
$languageOptions = [];
$languageOptions['any'] = acym_translation('ACYM_ANY');
$languages = acym_getLanguages(true);
foreach ($languages as $language) {
$languageOptions[$language->language] = $language->name;
}
if (empty($option['default'])) {
$option['default'] = acym_getVar('string', 'language');
if (acym_isMultilingual() && (empty($option['default']) || $option['default'] === 'main')) {
$option['default'] = $this->config->get('multilingual_default');
}
}
$currentOption .= acym_select(
$languageOptions,
$option['name'].$suffix,
empty($option['default']) ? null : $option['default'],
[
'onchange' => $updateFunction.'();',
'id' => $option['name'].$suffix,
]
);
$jsOptionsMerge[] = 'otherinfo += "| '.$option['name'].':" + jQuery(\'[name="'.$option['name'].$suffix.'"]\').val();';
} elseif ($option['type'] == 'custom') {
$currentOption .= $option['output'];
$jsOptionsMerge[] = $option['js'];
}
if (!empty($option['main']) || in_array($option['type'], ['pictures', 'checkbox'])) {
$outputStructure['topOptions'][$currentLabel] = $currentOption;
if ($option['type'] === 'checkbox' && $currentLabel === 'ACYM_DISPLAY' && (!isset($option['format']) || $option['format'])) {
$formatOption = '';
$formatOption .= ' ';
$jsOptionsMerge[] = 'var selectedFormatOption = jQuery(\'.button-radio-selected[acym-button-radio-group="dcontentFormat'.$suffix.'"]\')';
$jsOptionsMerge[] = 'if (!acym_helper.empty(selectedFormatOption)) otherinfo += "| format:" + selectedFormatOption.attr("acym-data-type");';
$outputStructure['topOptions']['ACYM_FORMAT'] = $formatOption;
}
continue;
}
if (empty($option['section'])) {
$option['section'] = 'ACYM_OTHER_OPTIONS';
}
$currentLabel = acym_translation($currentLabel);
if (!empty($option['tooltip'])) {
$currentLabel .= ' '.acym_info($option['tooltip'], 'acym_plugin_field_'.$option['name']);
}
$currentLabel = '';
$outputStructure['options'][$option['section']][$currentLabel] = $currentOption;
}
if (!empty($outputStructure['options'])) {
foreach ($outputStructure['options'] as $section => $options) {
$formattedOptions = '';
foreach ($options as $label => $option) {
$formattedOptions .= ''.acym_translation('ACYM_FORMAT').' ';
$formatOption .= '';
$default = empty($defaultValues->format) ? 'TOP_LEFT' : $defaultValues->format;
$formats = ['TOP_LEFT', 'TOP_RIGHT', 'TITLE_IMG', 'TITLE_IMG_RIGHT', 'CENTER_IMG', 'TOP_IMG', 'COL_LEFT', 'COL_RIGHT'];
foreach ($formats as $oneFormat) {
$class = 'button-radio';
if ($default === $oneFormat) $class .= ' button-radio-selected';
$formatOption .= '';
}
$formatOption .= ' ';
if ($type === 'grouped') {
$formatOption .= ''.acym_translation('ACYM_ALTERNATE').acym_info('ACYM_ALTERNATE_DESC').' ';
$formatOption .= '';
$formatOption .= acym_boolean(
'alternate'.$suffix,
!empty($defaultValues->alternate),
'alternate'.$suffix,
['onclick' => $updateFunction.'();']
);
$formatOption .= ' ';
$jsOptionsMerge[] = 'var alternate = jQuery(\'input[name="alternate'.$suffix.'"]:checked\').val();';
$jsOptionsMerge[] = 'if (!acym_helper.empty(alternate)) otherinfo += "| alternate";';
}
$formatOption .= ''.$label;
$formattedOptions .= ' ';
}
$outputStructure['topOptions'][$section] = $formattedOptions;
}
}
$output = '';
if (!empty($outputStructure['topOptions'])) {
foreach ($outputStructure['topOptions'] as $label => $oneOption) {
$output .= '';
$output .= '';
}
}
$output .= '
';
if ($type == 'individual') {
acym_trigger('displayCustomViewEditor', [&$output], 'plgAcym'.ucfirst($dynamicIdentifier));
$output .= '';
}
return $output;
}
public function translateItem(object &$item, object &$tag, string $referenceTable, int $referenceId = 0): void
{
if (!acym_isExtensionActive('com_falang')) {
return;
}
if (!empty($tag->falang)) {
$langId = $tag->falang;
} elseif (!empty($tag->lang)) {
$langId = intval(substr($tag->lang, strpos($tag->lang, ',') + 1));
} elseif (!empty($this->contextLanguage)) {
$languages = acym_loadObjectList('SELECT `lang_id`, `lang_code` FROM #__languages', 'lang_code');
if (!empty($languages[$this->contextLanguage])) {
$langId = $languages[$this->contextLanguage]->lang_id;
}
}
if (empty($langId)) {
return;
}
if (empty($referenceId)) {
$referenceId = $tag->id;
}
$translations = acym_loadObjectList(
'SELECT `reference_field`, `value`
FROM `#__falang_content`
WHERE `published` = 1
AND `reference_table` = '.acym_escapeDB($referenceTable).'
AND `language_id` = '.intval($langId).'
AND `reference_id` = '.intval($referenceId)
);
if (empty($translations)) {
return;
}
foreach ($translations as $oneTranslation) {
if (empty($oneTranslation->value)) {
continue;
}
$translatedField = $oneTranslation->reference_field;
$item->$translatedField = $oneTranslation->value;
}
}
public function createDummyEmailObject(int $mailId, string $code, string $previewBody): object
{
if (!empty($mailId)) {
$mailClass = new MailClass();
$email = $mailClass->getOneById($mailId);
}
if (empty($email)) {
$email = new \stdClass();
$email->id = 0;
$email->name = '';
$email->subject = '';
$email->from_name = '';
$email->from_email = '';
$email->reply_to_name = '';
$email->reply_to_email = '';
$email->bcc = '';
$email->links_language = '';
}
$language = acym_getVar('string', 'language', 'main');
if (!empty($language)) {
if ($language === 'main') {
$language = $this->config->get('multilingual_default', ACYM_DEFAULT_LANGUAGE);
}
$email->links_language = $language;
}
$email->creation_date = acym_date('now', 'Y-m-d H:i:s', false);
$email->creator_id = acym_currentUserId();
$email->thumbnail = '';
$email->drag_editor = '1';
$email->type = MailClass::TYPE_STANDARD;
$email->settings = '';
$email->stylesheet = '';
$email->attachments = '';
$email->body = $code;
$email->previewBody = $previewBody;
return $email;
}
}
'.$option.' ';
$formattedOptions .= ' | ||||||||