function resizePictures($input) { $this->destination = ACYMAILING_MEDIA . 'resized' . DS; acymailing_createDir($this->destination); $content = acymailing_absoluteURL($input); preg_match_all('#<img([^>]*)>#Ui', $content, $results); if (empty($results[1])) { return $input; } $replace = array(); foreach ($results[1] as $onepicture) { if (strpos($onepicture, 'donotresize') !== false) { continue; } if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) { continue; } $imageUrl = $path[1]; $base = str_replace(array('http://www.', 'https://www.', 'http://', 'https://'), '', ACYMAILING_LIVE); $replacements = array('https://www.' . $base, 'http://www.' . $base, 'https://' . $base, 'http://' . $base); foreach ($replacements as $oneReplacement) { if (strpos($imageUrl, $oneReplacement) === false) { continue; } $imageUrl = str_replace(array($oneReplacement, '/'), array(ACYMAILING_ROOT, DS), urldecode($imageUrl)); break; } $newPicture = $this->generateThumbnail($imageUrl); if (!$newPicture) { $newDimension = 'max-width:' . $this->maxWidth . 'px;max-height:' . $this->maxHeight . 'px;'; if (strpos($onepicture, 'style="') !== false) { $replace[$onepicture] = preg_replace('#style="([^"]*)"#Uis', 'style="' . $newDimension . '$1"', $onepicture); } else { $replace[$onepicture] = ' style="' . $newDimension . '" ' . $onepicture; } continue; } $newPicture['file'] = preg_replace('#^' . preg_quote(ACYMAILING_ROOT, '#') . '#i', ACYMAILING_LIVE, $newPicture['file']); $newPicture['file'] = str_replace(DS, '/', $newPicture['file']); $replaceImage = array(); $replaceImage[$path[1]] = $newPicture['file']; if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) { foreach ($resultsSize[0] as $i => $oneArg) { $newVal = strtolower($resultsSize[1][$i]) == 'width' ? $newPicture['width'] : $newPicture['height']; if ($newVal > $resultsSize[3][$i]) { continue; } $replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg); } } $replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture); } if (!empty($replace)) { $input = str_replace(array_keys($replace), $replace, $content); } return $input; }
function resizePictures($input) { $this->destination = ACYMAILING_MEDIA . 'resized' . DS; acymailing_createDir($this->destination); $content = acymailing_absoluteURL($input); preg_match_all('#<img([^>]*)>#Ui', $content, $results); if (empty($results[1])) { return $input; } $replace = array(); foreach ($results[1] as $onepicture) { if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) { continue; } $imageUrl = $path[1]; $otheracymailinglive = str_replace('http://www.', 'http://', ACYMAILING_LIVE); if ($otheracymailinglive == ACYMAILING_LIVE) { $otheracymailinglive = str_replace('http://', 'http://www.', ACYMAILING_LIVE); } if (strpos($imageUrl, ACYMAILING_LIVE) !== false || strpos($imageUrl, $otheracymailinglive) !== false) { $imageUrl = str_replace(array(ACYMAILING_LIVE, $otheracymailinglive, '/'), array(ACYMAILING_ROOT, ACYMAILING_ROOT, DS), urldecode($imageUrl)); } $newPicture = $this->generateThumbnail($imageUrl); if (!$newPicture) { continue; } $newPicture['file'] = str_replace(array(ACYMAILING_ROOT, DS), array(ACYMAILING_LIVE, '/'), $newPicture['file']); $replaceImage = array(); $replaceImage[$path[1]] = $newPicture['file']; if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) { foreach ($resultsSize[0] as $i => $oneArg) { $newVal = strtolower($resultsSize[1][$i]) == 'width' ? $newPicture['width'] : $newPicture['height']; if ($newVal > $resultsSize[3][$i]) { continue; } $replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg); } } $replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture); } if (!empty($replace)) { $input = str_replace(array_keys($replace), $replace, $content); } return $input; }
function form() { $mailid = acymailing_getCID('mailid'); $templateClass = acymailing_get('class.template'); $config =& acymailing_config(); if (!empty($mailid)) { $mailClass = acymailing_get('class.mail'); $mail = $mailClass->get($mailid); if (!empty($mail->tempid)) { $myTemplate = $templateClass->get($mail->tempid); } } else { $mail = new stdClass(); $mail->created = time(); $mail->published = 0; if ($this->type == 'followup') { $mail->published = 1; } $mail->visible = 1; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; $templateid = JRequest::getInt('templateid'); if (empty($templateid)) { $myTemplate = $templateClass->getDefault(); } else { $myTemplate = $templateClass->get($templateid); } if (!empty($myTemplate->tempid)) { $mail->body = acymailing_absoluteURL($myTemplate->body); $mail->altbody = $myTemplate->altbody; $mail->tempid = $myTemplate->tempid; $mail->subject = $myTemplate->subject; $mail->replyname = $myTemplate->replyname; $mail->replyemail = $myTemplate->replyemail; $mail->fromname = $myTemplate->fromname; $mail->fromemail = $myTemplate->fromemail; } if ($this->type == 'autonews') { $mail->frequency = 604800; } } $sentbyname = ''; if (!empty($mail->sentby)) { $db = JFactory::getDBO(); $db->setQuery('SELECT `name` FROM `#__users` WHERE `id`= ' . intval($mail->sentby) . ' LIMIT 1'); $sentbyname = $db->loadResult(); } $this->assignRef('sentbyname', $sentbyname); if (JRequest::getVar('task', '') == 'replacetags') { $mailerHelper = acymailing_get('helper.mailer'); JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('acymailing_replacetags', array(&$mail, false)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } } $extraInfos = ''; $values = new stdClass(); if ($this->type == 'followup') { $campaignid = JRequest::getInt('campaign', 0); $extraInfos .= '&campaign=' . $campaignid; $values->delay = acymailing_get('type.delay'); $this->assignRef('campaignid', $campaignid); } else { $listmailClass = acymailing_get('class.listmail'); $lists = $listmailClass->getLists($mailid); } acymailing_setTitle(JText::_($this->nameForm), $this->icon, $this->ctrl . '&task=edit&mailid=' . $mailid . $extraInfos); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_templates_view', 'all'))) { $bar->appendButton('Acypopup', 'acytemplate', JText::_('ACY_TEMPLATE'), "index.php?option=com_acymailing&ctrl=template&task=theme&tmpl=component", 750, 550); } if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acytags', $this->type); } if (in_array($this->type, array('news', 'followup')) && acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { JToolBarHelper::custom('replacetags', 'replacetag', '', JText::_('REPLACE_TAGS'), false); } $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::divider(); JToolBarHelper::custom('savepreview', 'acypreview', '', $buttonPreview, false); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); $values->maxupload = acymailing_bytes(ini_get('upload_max_filesize')) > acymailing_bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize'); $toggleClass = acymailing_get('helper.toggle'); $editor = acymailing_get('helper.editor'); $editor->setTemplate($mail->tempid); $editor->name = 'editor_body'; $editor->content = $mail->body; $editor->prepareDisplay(); $js = "function updateAcyEditor(htmlvalue){"; $js .= 'if(htmlvalue == \'0\'){window.document.getElementById("htmlfieldset").style.display = \'none\'}else{window.document.getElementById("htmlfieldset").style.display = \'block\'}'; $js .= '}'; $js .= 'window.addEvent(\'load\', function(){ updateAcyEditor(' . $mail->html . '); });'; $script = 'function addFileLoader(){ var divfile=window.document.getElementById("loadfile"); var input = document.createElement(\'input\'); input.type = \'file\'; input.size = \'30\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; if (!ACYMAILING_J16) { $script .= 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script .= 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(window.document.getElementById("subject").value.length < 2){alert(\'' . JText::_('ENTER_SUBJECT', true) . '\'); return false;}'; $script .= $editor->jsCode(); if (!ACYMAILING_J16) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,tempid){\r\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\r\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2) vartextarea.innerHTML = newtext;\r\n\t\t\tdocument.getElementById('tempid').value = tempid;\r\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\r\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\r\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\r\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\r\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\r\n\t\t}\r\n\t\t"; $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); if ($this->type == 'autonews') { JHTML::_('behavior.modal', 'a.modal'); $this->assign('delay', acymailing_get('type.delay')); $this->assign('generatingMode', acymailing_get('type.generatemode')); $link = 'index.php?option=com_acymailing&tmpl=component&ctrl=email&task=edit&mailid=notification_autonews'; $values->editnotification = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}"><button class="btn" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>'; } $this->assignRef('toggleClass', $toggleClass); $this->assignRef('lists', $lists); $this->assignRef('editor', $editor); $this->assignRef('mail', $mail); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); $this->assignRef('values', $values); $this->assignRef('config', $config); }
<?php echo acymailing_absoluteURL(nl2br($row->description)); ?> </div> <div style="display:none" id="stylesheet_<?php echo $row->tempid; ?> "><?php echo $row->stylesheet; ?> </div> <div style="display:none" id="htmlcontent_<?php echo $row->tempid; ?> "><?php echo acymailing_absoluteURL($row->body); ?> </div> <div style="display:none" id="textcontent_<?php echo $row->tempid; ?> "><?php echo $row->altbody; ?> </div> <div style="display:none" id="subject_<?php echo $row->tempid; ?> "><?php echo $row->subject; ?>
function form() { $tempid = acymailing_getCID('tempid'); $app =& JFactory::getApplication(); $config = acymailing_config(); if (!empty($tempid)) { $templateClass = acymailing_get('class.template'); $template = $templateClass->get($tempid); if (!empty($template->body)) { $template->body = acymailing_absoluteURL($template->body); } } else { $template->body = ''; $template->tempid = 0; $template->published = 1; } $editor = acymailing_get('helper.editor'); $editor->setTemplate($template->tempid); $editor->name = 'editor_body'; $editor->content = $template->body; $editor->prepareDisplay(); if (version_compare(JVERSION, '1.6.0', '<')) { $script = 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script = 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(window.document.getElementById("name").value.length < 2){alert(\'' . JText::_('ENTER_TITLE', true) . '\'); return false;}'; $script .= "if(pressbutton == 'test' && window.document.getElementById('sendtest') && window.document.getElementById('sendtest').style.display == 'none'){ window.document.getElementById('sendtest').style.display = 'block'; return false;}"; $script .= $editor->jsCode(); if (version_compare(JVERSION, '1.6.0', '<')) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $script .= 'function addStyle(){ var myTable=window.document.getElementById("classtable"); var newline = document.createElement(\'tr\'); var column = document.createElement(\'td\'); var column2 = document.createElement(\'td\'); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.size = \'30\'; input2.size = \'50\'; input.name = \'otherstyles[classname][]\'; input2.name = \'otherstyles[style][]\'; input.value = "' . JText::_('CLASS_NAME', true) . '"; input2.value = "' . JText::_('CSS_STYLE', true) . '"; column.appendChild(input); column2.appendChild(input2); newline.appendChild(column); newline.appendChild(column2); myTable.appendChild(newline); }'; $script .= 'var currentValueId = \'\'; function showthediv(valueid,e) { if(currentValueId != valueid){ try{ document.getElementById(\'wysija\').style.left = e.pageX-50+"px"; document.getElementById(\'wysija\').style.top = e.pageY-40+"px"; }catch(err){ document.getElementById(\'wysija\').style.left = e.x-50+"px"; document.getElementById(\'wysija\').style.top = e.y-40+"px"; } currentValueId = valueid; } document.getElementById(\'wysija\').style.display = \'block\'; initDiv(); } function spanChange(span) { input = currentValueId; if (document.getElementById(span).className == span.toLowerCase()+"elementselected") { document.getElementById(span).className = span.toLowerCase()+"element"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-weight *: *bold(;)?/i, ""); } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-style *: *italic(;)?/i, ""); } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration=""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/text-decoration *: *underline(;)?/i,""); } } else{ document.getElementById(span).className = span.toLowerCase()+"elementselected"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = "bold"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-weight:bold;"; } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = "italic"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-style:italic;"; } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration="underline"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "text-decoration:underline;"; } } } function getValueSelect() { selec = currentValueId; var myRegex2 = new RegExp(/font-size *:[^;]*;/i); var MyValue = document.getElementById("style_select_wysija").value; document.getElementById("name_"+currentValueId).style.fontSize = MyValue; if(document.getElementById("style_"+currentValueId).value.search(myRegex2) != -1){ if(MyValue == ""){ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, ""); } else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, "font-size:"+MyValue+";"); } } else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-size:"+MyValue+";"; } } function initDiv(){ var RegexSize = new RegExp(/font-size *:[^;]*(;)?/gi); var RegexColor = new RegExp(/([^a-z-])color *:[^;]*(;)?/gi); document.getElementById("colorexamplewysijacolor").style.backgroundColor = "#000000"; document.getElementById("colordivwysijacolor").style.display = "none"; spaced = document.getElementById("style_"+currentValueId).value.substr(0,1); if(spaced != " "){ stringToQuery = \' \' + document.getElementById("style_"+currentValueId).value; } else{ stringToQuery = document.getElementById("style_"+currentValueId).value; } NewColor = stringToQuery.match(RegexColor); if(NewColor != null){ NewColor = NewColor[0].match(/:[^;!]*/gi); NewColor = NewColor[0].replace(/(:| )/gi,""); document.getElementById("colorexamplewysijacolor").style.backgroundColor = NewColor; } document.getElementById("U").className = "uelement"; document.getElementById("I").className = "ielement"; document.getElementById("B").className = "belement"; if(document.getElementById("style_"+currentValueId).value.search(/font-weight: *bold(;)?/i) != -1){ document.getElementById("B").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/font-style: *italic(;)?/i) != -1){ document.getElementById("I").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/text-decoration: *underline(;)?/i) != -1){ document.getElementById("U").className += "selected"; } NewSize = stringToQuery.match(RegexSize); document.getElementById("style_select_wysija").options[0].selected = true; if(NewSize != null){ NewSize = NewSize[0].match(/:[^;]*/gi); NewSize = NewSize[0].replace(" ",""); NewSize = NewSize.substr(1); for(var i = 0; i < document.getElementById("style_select_wysija").length; i++) { if(document.getElementById("style_select_wysija").options[i].value == NewSize){ document.getElementById("style_select_wysija").options[i].selected = true; } } } }'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = null; $infos->receiver_type = $app->getUserStateFromRequest($paramBase . ".receiver_type", 'receiver_type', '', 'string'); $infos->test_email = $app->getUserStateFromRequest($paramBase . ".test_email", 'test_email', '', 'string'); acymailing_setTitle(JText::_('ACY_TEMPLATE'), 'acytemplate', 'template&task=edit&tempid=' . $tempid); $bar =& JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acytags'); } JToolBarHelper::divider(); JToolBarHelper::custom('test', 'send', '', JText::_('SEND_TEST'), false); JToolBarHelper::spacer(); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'template-form'); $this->assignRef('editor', $editor); $receiverClass = acymailing_get('type.testreceiver'); $this->assignRef('receiverClass', $receiverClass); $this->assignRef('template', $template); $colorBox = acymailing_get('type.color'); $this->assignRef('colorBox', $colorBox); $this->assignRef('infos', $infos); jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $this->assignRef('tabs', $tabs); }
public function acymailing_replaceusertags(&$email, &$user, $send = true) { if (!$email->sendHTML) { return; } $this->_applyTemplate($email, $send); $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing_absoluteURL($email->body); $email->body = preg_replace('#< *img([^>]*)(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', '<img$1 align="$4" hspace="5" $2$3$4', $email->body); if (!preg_match('#(<thead|<tfoot|< *tbody *[^> ]+ *>)#Ui', $email->body)) { $email->body = preg_replace('#< *\\/? *tbody *>#Ui', '', $email->body); } $email->body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', array($this, '_convertSpaces'), $email->body); $this->fixPictureSize($email->body); $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->fixPictureDim($email->body); }
public function textVersion($html, $fullConvert = true) { $html = acymailing_absoluteURL($html); if ($fullConvert) { $html = preg_replace('# +#', ' ', $html); $html = str_replace(array("\n", "\r", "\t"), '', $html); } $removepictureslinks = "#< *a[^>]*> *< *img[^>]*> *< *\\/ *a *>#isU"; $removeScript = "#< *script(?:(?!< */ *script *>).)*< */ *script *>#isU"; $removeStyle = "#< *style(?:(?!< */ *style *>).)*< */ *style *>#isU"; $removeStrikeTags = '#< *strike(?:(?!< */ *strike *>).)*< */ *strike *>#iU'; $replaceByTwoReturnChar = '#< *(h1|h2)[^>]*>#Ui'; $replaceByStars = '#< *li[^>]*>#Ui'; $replaceByReturnChar1 = '#< */ *(li|td|dt|tr|div|p)[^>]*> *< *(li|td|dt|tr|div|p)[^>]*>#Ui'; $replaceByReturnChar = '#< */? *(br|p|h1|h2|legend|h3|li|ul|dd|dt|h4|h5|h6|tr|td|div)[^>]*>#Ui'; $replaceLinks = '/< *a[^>]*href *= *"([^#][^"]*)"[^>]*>(.+)< *\\/ *a *>/Uis'; $text = preg_replace(array($removepictureslinks, $removeScript, $removeStyle, $removeStrikeTags, $replaceByTwoReturnChar, $replaceByStars, $replaceByReturnChar1, $replaceByReturnChar, $replaceLinks), array('', '', '', '', "\n\n", "\n* ", "\n", "\n", '${2} ( ${1} )'), $html); $text = preg_replace('#(<|&\\#60;)([^ \\n\\r\\t])#i', '< ${2}', $text); $text = str_replace(array(" ", " "), ' ', strip_tags($text)); $text = trim(@html_entity_decode($text, ENT_QUOTES, 'UTF-8')); if ($fullConvert) { $text = preg_replace('# +#', ' ', $text); $text = preg_replace('#\\n *\\n\\s+#', "\n\n", $text); } return $text; }
function test() { if (!$this->isAllowed($this->aclCat, 'manage')) { return; } $this->store(); $tempid = acymailing_getCID('tempid'); $test_selection = JRequest::getVar('test_selection', '', '', 'string'); if (empty($tempid) or empty($test_selection)) { return; } $mailer = acymailing_get('helper.mailer'); $mailer->report = true; $config = acymailing_config(); $subscriberClass = acymailing_get('class.subscriber'); $userHelper = acymailing_get('helper.user'); JPluginHelper::importPlugin('acymailing'); $dispatcher = JDispatcher::getInstance(); $receivers = array(); if ($test_selection == 'users') { $receiverEntry = JRequest::getVar('test_emails', '', '', 'string'); if (!empty($receiverEntry)) { if (substr_count($receiverEntry, '@') > 1) { $receivers = explode(',', trim(preg_replace('# +#', '', $receiverEntry))); } else { $receivers[] = trim($receiverEntry); } } } else { $gid = JRequest::getInt('test_group', '-1'); if ($gid == -1) { return false; } $db = JFactory::getDBO(); if (!ACYMAILING_J16) { $db->setQuery('SELECT email FROM ' . acymailing_table('users', false) . ' WHERE gid = ' . intval($gid)); } else { $db->setQuery('SELECT u.email FROM ' . acymailing_table('users', false) . ' AS u JOIN ' . acymailing_table('user_usergroup_map', false) . ' AS ugm ON u.id = ugm.user_id WHERE ugm.group_id = ' . intval($gid)); } $receivers = acymailing_loadResultArray($db); } if (empty($receivers)) { acymailing_enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return $this->edit(); } $classTemplate = acymailing_get('class.template'); $myTemplate = $classTemplate->get($tempid); $myTemplate->sendHTML = 1; $myTemplate->mailid = 0; $myTemplate->template = $myTemplate; if (empty($myTemplate->subject)) { $myTemplate->subject = $myTemplate->name; } if (empty($myTemplate->altBody)) { $myTemplate->altbody = $mailer->textVersion($myTemplate->body); } $dispatcher->trigger('acymailing_replacetags', array(&$myTemplate, true)); $myTemplate->body = acymailing_absoluteURL($myTemplate->body); $result = true; foreach ($receivers as $receiveremail) { $copy = $myTemplate; $mailer->clearAll(); $mailer->setFrom($copy->fromemail, $copy->fromname); if (!empty($copy->replyemail)) { $replyToName = $config->get('add_names', true) ? $mailer->cleanText($copy->replyname) : ''; $mailer->AddReplyTo($mailer->cleanText($copy->replyemail), $replyToName); } $receiver = $subscriberClass->get($receiveremail); if (empty($receiver->subid)) { if ($userHelper->validEmail($receiveremail)) { $newUser = new stdClass(); $newUser->email = $receiveremail; $subscriberClass->sendConf = false; $subid = $subscriberClass->save($newUser); $receiver = $subscriberClass->get($subid); } if (empty($receiver->subid)) { continue; } } $addedName = $config->get('add_names', true) ? $mailer->cleanText($receiver->name) : ''; $mailer->AddAddress($mailer->cleanText($receiver->email), $addedName); $dispatcher->trigger('acymailing_replaceusertags', array(&$copy, &$receiver, true)); $mailer->isHTML(true); $mailer->Body = $copy->body; $mailer->Subject = $copy->subject; if ($config->get('multiple_part', false)) { $mailer->AltBody = $copy->altbody; } $mailer->send(); } return $this->edit(); }
static function absoluteURL($text) { return acymailing_absoluteURL($text); }
function form() { $this->chosen = false; $app = JFactory::getApplication(); $mailid = acymailing_getCID('mailid'); $templateClass = acymailing_get('class.template'); $config =& acymailing_config(); $my = JFactory::getUser(); if (!empty($mailid)) { $mailClass = acymailing_get('class.mail'); $mail = $mailClass->get($mailid); if (!empty($mail->tempid)) { $myTemplate = $templateClass->get($mail->tempid); } if (empty($mail->mailid)) { acymailing_display('Newsletter ' . $mailid . ' not found', 'error'); $mailid = 0; } } if (empty($mailid)) { $mail = new stdClass(); $mail->created = time(); $mail->published = 0; $mail->thumb = ''; if ($this->type == 'followup') { $mail->published = 1; } $mail->visible = 1; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; $templateid = JRequest::getInt('templateid'); if (empty($templateid) and !empty($my->email)) { $subscriberClass = acymailing_get('class.subscriber'); $currentSubscriber = $subscriberClass->get($my->email); if (!empty($currentSubscriber->template)) { $templateid = $currentSubscriber->template; } } if (empty($templateid)) { $myTemplate = $templateClass->getDefault(); } else { $myTemplate = $templateClass->get($templateid); } if (!empty($myTemplate->tempid)) { $mail->body = acymailing_absoluteURL($myTemplate->body); $mail->altbody = $myTemplate->altbody; $mail->tempid = $myTemplate->tempid; $mail->subject = $myTemplate->subject; $mail->replyname = $myTemplate->replyname; $mail->replyemail = $myTemplate->replyemail; $mail->fromname = $myTemplate->fromname; $mail->fromemail = $myTemplate->fromemail; } if ($this->type == 'autonews') { $mail->frequency = 0; } if (!$app->isAdmin()) { if ($config->get('frontend_sender', 0)) { $mail->fromname = $my->name; $mail->fromemail = $my->email; } else { if (empty($mail->fromname)) { $mail->fromname = $config->get('from_name'); } if (empty($mail->fromemail)) { $mail->fromemail = $config->get('from_email'); } } if ($config->get('frontend_reply', 0)) { $mail->replyname = $my->name; $mail->replyemail = $my->email; } else { if (empty($mail->replyname)) { $mail->replyname = $config->get('reply_name'); } if (empty($mail->replyemail)) { $mail->replyemail = $config->get('reply_email'); } } } } $sentbyname = ''; if (!empty($mail->sentby)) { $db = JFactory::getDBO(); $db->setQuery('SELECT `name` FROM `#__users` WHERE `id`= ' . intval($mail->sentby) . ' LIMIT 1'); $sentbyname = $db->loadResult(); } $this->assignRef('sentbyname', $sentbyname); if (JRequest::getVar('task', '') == 'replacetags') { $mailerHelper = acymailing_get('helper.mailer'); $templateClass = acymailing_get('class.template'); $mail->template = $templateClass->get($mail->tempid); JPluginHelper::importPlugin('acymailing'); $mailerHelper->triggerTagsWithRightLanguage($mail, false); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } } $extraInfos = ''; $values = new stdClass(); if ($this->type == 'followup') { $campaignid = JRequest::getInt('campaign', 0); $extraInfos .= '&campaign=' . $campaignid; $values->delay = acymailing_get('type.delay'); $this->assignRef('campaignid', $campaignid); } else { $listmailClass = acymailing_get('class.listmail'); $lists = $listmailClass->getLists($mailid); } if ($app->isAdmin()) { acymailing_setTitle(JText::_($this->nameForm), $this->icon, $this->ctrl . '&task=edit&mailid=' . $mailid . $extraInfos); $bar = JToolBar::getInstance('toolbar'); if (acymailing_isAllowed($config->get('acl_templates_view', 'all'))) { $bar->appendButton('Acypopup', 'acytemplate', JText::_('ACY_TEMPLATE'), "index.php?option=com_acymailing&ctrl=template&task=theme&tmpl=component", 750, 550); } if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acypopup', 'acytags', JText::_('TAGS'), JURI::base() . "index.php?option=com_acymailing&ctrl=tag&task=tag&tmpl=component&type=" . $this->type, 780, 550); } if (in_array($this->type, array('news', 'followup')) && acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { JToolBarHelper::custom('replacetags', 'replacetag', '', JText::_('REPLACE_TAGS'), false); } $buttonPreview = JText::_('ACY_PREVIEW'); if ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::divider(); JToolBarHelper::custom('savepreview', 'acypreview', '', $buttonPreview, false); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->doc); } $values->maxupload = acymailing_bytes(ini_get('upload_max_filesize')) > acymailing_bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize'); $toggleClass = acymailing_get('helper.toggle'); if (!$app->isAdmin()) { $toggleClass->ctrl = 'frontnewsletter'; $toggleClass->extra = '&listid=' . JRequest::getInt('listid'); $copyAllLists = $lists; foreach ($copyAllLists as $listid => $oneList) { if (!$oneList->published or empty($my->id)) { unset($lists[$listid]); continue; } if ($oneList->access_manage == 'all') { continue; } if ((int) $my->id == (int) $oneList->userid) { continue; } if (!acymailing_isAllowed($oneList->access_manage)) { unset($lists[$listid]); continue; } } if (empty($lists)) { $app = JFactory::getApplication(); $app->enqueueMessage('You don\'t have the rights to add or edit an e-mail', 'error'); $app->redirect(acymailing_completeLink('frontnewsletter', false, true)); } } $editor = acymailing_get('helper.editor'); $editor->setTemplate($mail->tempid); $editor->name = 'editor_body'; $editor->content = $mail->body; $editor->prepareDisplay(); $js = "function updateAcyEditor(htmlvalue){"; $js .= 'if(htmlvalue == \'0\'){window.document.getElementById("htmlfieldset").style.display = \'none\'}else{window.document.getElementById("htmlfieldset").style.display = \'block\'}'; $js .= '}'; $js .= 'window.addEvent(\'load\', function(){ updateAcyEditor(' . $mail->html . '); });'; $script = 'function addFileLoader(){ var divfile=window.document.getElementById("loadfile"); var input = document.createElement(\'input\'); input.type = \'file\'; input.style.width = \'auto\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; if (!ACYMAILING_J16) { $script .= 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script .= 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(pressbutton == \'save\' || pressbutton == \'apply\' || pressbutton == \'savepreview\' || pressbutton == \'replacetags\'){ var emailVars = ["fromemail","replyemail"]; var val = ""; for(var key in emailVars){ if(isNaN(key)) continue; val = document.getElementById(emailVars[key]).value; if(!validateEmail(val, emailVars[key])){ return; } } }'; $script .= 'if(window.document.getElementById("subject").value.length < 2){alert(\'' . JText::_('ENTER_SUBJECT', true) . '\'); return false;}'; $script .= $editor->jsCode(); if (!ACYMAILING_J16) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,tempid){\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2) vartextarea.innerHTML = newtext;\n\t\t\tdocument.getElementById('tempid').value = tempid;\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\n\t\t\t" . $editor->setEditorStylesheet('tempid') . "\n\t\t}\n\t\t"; if ($mail->html == 1) { $script .= "var zoneEditor = 'editor_body';"; } else { $script .= "var zoneEditor = 'altbody';"; } $script .= "\n\t\t\tvar zoneToTag = 'altbody';\n\t\t\tfunction initTagZone(html){ if(html == 0){ zoneEditor = 'altbody'; }else{ zoneEditor = 'editor_body'; }}\n\t\t"; $script .= "var previousSelection = false;\n\t\t\tfunction insertTag(tag){\n\t\t\t\tif(zoneEditor == 'editor_body'){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tjInsertEditorText(tag,'editor_body',previousSelection);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch(err){\n\t\t\t\t\t\talert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else{\n\t\t\t\t\ttry{\n\t\t\t\t\t\tsimpleInsert(document.getElementById(zoneToTag), tag);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t} catch(err){\n\t\t\t\t\t\talert('Error inserting the tag in the '+ zoneToTag + 'zone. Please copy/paste it manually in your Newsletter.');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t"; $script .= "function simpleInsert(myField, myValue) {\n\t\t\t\tif (document.selection) {\n\t\t\t\t\tmyField.focus();\n\t\t\t\t\tsel = document.selection.createRange();\n\t\t\t\t\tsel.text = myValue;\n\t\t\t\t} else if (myField.selectionStart || myField.selectionStart == '0') {\n\t\t\t\t\tvar startPos = myField.selectionStart;\n\t\t\t\t\tvar endPos = myField.selectionEnd;\n\t\t\t\t\tmyField.value = myField.value.substring(0, startPos)\n\t\t\t\t\t\t+ myValue\n\t\t\t\t\t\t+ myField.value.substring(endPos, myField.value.length);\n\t\t\t\t} else {\n\t\t\t\t\tmyField.value += myValue;\n\t\t\t\t}\n\t\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); if ($this->type == 'autonews') { JHTML::_('behavior.modal', 'a.modal'); $this->assign('frequencyType', acymailing_get('type.frequency')); $this->assign('generatingMode', acymailing_get('type.generatemode')); } $this->assignRef('toggleClass', $toggleClass); $this->assignRef('lists', $lists); $this->assignRef('editor', $editor); $this->assignRef('mail', $mail); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); $this->assignRef('values', $values); $this->assignRef('config', $config); }
public function acymailing_replaceusertags(&$email, &$user, $send = true) { if (!$email->sendHTML) { return; } if (!acymailing_level(1) && !empty($email->type) && $email->type == 'news') { $pict = '<div style="text-align:center;margin:10px auto;display:block;"><a target="_blank" href="https://www.acyba.com"><img alt="Powered by AcyMailing" src="media/com_acymailing/images/poweredby.png" /></a></div>'; if (strpos($email->body, '</body>')) { $email->body = str_replace('</body>', $pict . '</body>', $email->body); } else { $email->body .= $pict; } } $this->_applyTemplate($email, $send); $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing_absoluteURL($email->body); if (preg_match_all('#< *img([^>]*)>#Ui', $email->body, $allPictures)) { foreach ($allPictures[0] as $i => $onePict) { if (strpos($onePict, 'align=') !== false) { continue; } if (!preg_match('#(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', $onePict, $pictParams)) { continue; } $newPict = str_replace('<img', '<img align="' . $pictParams[3] . '" ', $onePict); $email->body = str_replace($onePict, $newPict, $email->body); if (strpos($onePict, 'hspace=') !== false) { continue; } $hspace = 5; if (preg_match('#margin(-right|-left)? *:([^";]*)#i', $onePict, $margins)) { $currentMargins = explode(' ', trim($margins[2])); $myMargin = count($currentMargins) > 1 ? $currentMargins[1] : $currentMargins[0]; if (strpos($myMargin, 'px') !== false) { $hspace = preg_replace('#[^0-9]#i', '', $myMargin); } } $lastPict = str_replace('<img', '<img hspace="' . $hspace . '" ', $newPict); $email->body = str_replace($newPict, $lastPict, $email->body); } } if (!preg_match('#(<thead|<tfoot|< *tbody *[^> ]+ *>)#Ui', $email->body)) { $email->body = preg_replace('#< *\\/? *tbody *>#Ui', '', $email->body); } $email->body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', array($this, '_convertSpaces'), $email->body); $this->fixPictureSize($email->body); $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->fixPictureDim($email->body); }
echo ACYMAILING_LIVE . strip_tags($row->thumb); ?> " style="float:left;width:100px;margin-right:10px;" /> </a> <?php } ?> <a href="<?php echo acymailing_completeLink('template&task=edit&tempid=' . $row->tempid); ?> "><?php echo $row->name; ?> </a><br/> <?php echo acymailing_absoluteURL($row->description); ?> </td> <td class="order" style="text-align:center;"> <span><?php echo $this->pagination->orderUpIcon($i, $this->order->reverse xor $row->ordering >= @$this->rows[$i - 1]->ordering, $this->order->orderUp, 'Move Up', $this->order->ordering); ?> </span> <span><?php echo $this->pagination->orderDownIcon($i, $a, $this->order->reverse xor $row->ordering <= @$this->rows[$i + 1]->ordering, $this->order->orderDown, 'Move Down', $this->order->ordering); ?> </span> <input type="text" name="order[]" size="5" <?php if (!$this->order->ordering) { echo 'disabled="disabled"'; }
function handlepict(&$content, $templatepath) { $content = acymailing_absoluteURL($content); if (!preg_match_all('#<img[^>]*src="([^"]*)"#i', $content, $pictures)) { return true; } $pictFolder = rtrim($templatepath, DS) . DS . 'images'; if (!acymailing_createDir($pictFolder)) { return false; } $replace = array(); foreach ($pictures[1] as $onePict) { if (isset($replace[$onePict])) { continue; } $location = str_replace(array(ACYMAILING_LIVE, '/'), array(ACYMAILING_ROOT, DS), $onePict); if (strpos($location, 'http') === 0) { continue; } if (!file_exists($location)) { continue; } $filename = basename($location); while (file_exists($pictFolder . DS . $filename)) { $filename = rand(0, 99) . $filename; } if (JFile::copy($location, $pictFolder . DS . $filename) !== true) { acymailing_display('Could not copy the file from ' . $location . ' to ' . $pictFolder . DS . $filename, 'error'); return false; } $replace[$onePict] = 'images/' . $filename; } $content = str_replace(array_keys($replace), $replace, $content); return true; }
public function acymailing_replaceusertags(&$email, &$user, $send = true) { if (!$email->sendHTML) { return; } $this->_applyTemplate($email, $send); $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing_absoluteURL($email->body); if (preg_match_all('#< *img([^>]*)>#Ui', $email->body, $allPictures)) { foreach ($allPictures[0] as $i => $onePict) { if (strpos($onePict, 'align=') !== false) { continue; } if (!preg_match('#(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', $onePict, $pictParams)) { continue; } $newPict = str_replace('<img', '<img align="' . $pictParams[3] . '" ', $onePict); $email->body = str_replace($onePict, $newPict, $email->body); if (strpos($onePict, 'hspace=') !== false) { continue; } $hspace = 5; if (preg_match('#margin(-right|-left)? *:([^";]*)#i', $onePict, $margins)) { $currentMargins = explode(' ', trim($margins[2])); $myMargin = count($currentMargins) > 1 ? $currentMargins[1] : $currentMargins[0]; if (strpos($myMargin, 'px') !== false) { $hspace = preg_replace('#[^0-9]#i', '', $myMargin); } } $lastPict = str_replace('<img', '<img hspace="' . $hspace . '" ', $newPict); $email->body = str_replace($newPict, $lastPict, $email->body); } } if (!preg_match('#(<thead|<tfoot|< *tbody *[^> ]+ *>)#Ui', $email->body)) { $email->body = preg_replace('#< *\\/? *tbody *>#Ui', '', $email->body); } $email->body = preg_replace_callback('/src="([^"]* [^"]*)"/Ui', array($this, '_convertSpaces'), $email->body); $this->fixPictureSize($email->body); $acypluginsHelper = acymailing_get('helper.acyplugins'); $acypluginsHelper->fixPictureDim($email->body); }
echo rtrim(JURI::root(), '/') . '/' . strip_tags($row->thumb); ?> " style="float:left;width:100px;margin-right:10px;"/> </a> <?php } ?> <a href="<?php echo acymailing_completeLink('template&task=edit&tempid=' . $row->tempid); ?> "><?php echo acymailing_dispSearch($row->name, $this->pageInfo->search); ?> </a><br/> <?php echo acymailing_absoluteURL(nl2br($row->description)); ?> </td> <?php if (!ACYMAILING_J30) { ?> <td class="order" style="text-align:center;"> <span><?php echo $this->pagination->orderUpIcon($i, $this->order->reverse xor $row->ordering >= @$this->rows[$i - 1]->ordering, $this->order->orderUp, 'Move Up', $this->order->ordering); ?> </span> <span><?php echo $this->pagination->orderDownIcon($i, $a, $this->order->reverse xor $row->ordering <= @$this->rows[$i + 1]->ordering, $this->order->orderDown, 'Move Down', $this->order->ordering); ?> </span> <input type="text" name="order[]" size="5" <?php
function form() { JHTML::_('behavior.modal', 'a.modal'); $tempid = acymailing_getCID('tempid'); $app = JFactory::getApplication(); $config = acymailing_config(); if (!empty($tempid)) { $templateClass = acymailing_get('class.template'); $template = $templateClass->get($tempid); if (!empty($template->body)) { $template->body = acymailing_absoluteURL($template->body); } if (empty($template->tempid)) { acymailing_display('Template ' . $tempid . ' not found', 'error'); $tempid = 0; } } if (empty($tempid)) { $template = new stdClass(); $template->body = ''; $template->tempid = 0; $template->published = 1; $template->access = 'all'; $template->category = ''; $template->thumb = ''; $template->readmore = ''; } $editor = acymailing_get('helper.editor'); $editor->setTemplate($template->tempid); $editor->name = 'editor_body'; $editor->content = $template->body; $editor->prepareDisplay(); if (!ACYMAILING_J16) { $script = 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script = 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(pressbutton == \'save\' || pressbutton == \'test\' || pressbutton == \'apply\'){ var emailVars = ["fromemail","replyemail"]; var val = ""; for(var key in emailVars){ if(isNaN(key)) continue; val = document.getElementById(emailVars[key]).value; if(!validateEmail(val, emailVars[key])){ return; } } }'; $script .= 'if(window.document.getElementById("name").value.length < 2){alert(\'' . JText::_('ENTER_TITLE', true) . '\'); return false;}'; $script .= "if(pressbutton == 'test' && window.document.getElementById('sendtest') && window.document.getElementById('sendtest').style.display == 'none'){ window.document.getElementById('sendtest').style.display = 'block'; return false;}"; $script .= $editor->jsCode(); if (!ACYMAILING_J16) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $script .= 'function addStyle(){ var myTable=window.document.getElementById("classtable"); var newline = document.createElement(\'tr\'); var column = document.createElement(\'td\'); var column2 = document.createElement(\'td\'); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.style.width = \'180px\'; input2.style.width = \'200px\'; input.name = \'otherstyles[classname][]\'; input2.name = \'otherstyles[style][]\'; input.placeholder = "' . str_replace('"', '\\"', JText::_('CLASS_NAME', true)) . '"; input2.placeholder = "' . str_replace('"', '\\"', JText::_('CSS_STYLE', true)) . '"; column.appendChild(input); column2.appendChild(input2); newline.appendChild(column); newline.appendChild(column2); myTable.appendChild(newline); }'; $script .= 'var currentValueId = \'\'; function showthediv(valueid, e){ if(currentValueId != valueid){ try{ document.getElementById(\'wysija\').style.left = jQuery(e.target).position().left-50+"px"; document.getElementById(\'wysija\').style.top = jQuery(e.target).position().top-40+"px"; }catch(err){ document.getElementById(\'wysija\').style.left = e.x-50+"px"; document.getElementById(\'wysija\').style.top = e.y-40+"px"; } currentValueId = valueid; } document.getElementById(\'wysija\').style.display = \'block\'; initDiv(); } function spanChange(span){ input = currentValueId; if (document.getElementById(span).className == span.toLowerCase()+"elementselected"){ document.getElementById(span).className = span.toLowerCase()+"element"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-weight *: *bold(;)?/i, ""); } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = ""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/font-style *: *italic(;)?/i, ""); } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration=""; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(/text-decoration *: *underline(;)?/i,""); } }else{ document.getElementById(span).className = span.toLowerCase()+"elementselected"; if(span == "B"){ document.getElementById("name_"+currentValueId).style.fontWeight = "bold"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-weight:bold;"; } if(span == "I"){ document.getElementById("name_"+currentValueId).style.fontStyle = "italic"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-style:italic;"; } if(span == "U"){ document.getElementById("name_"+currentValueId).style.textDecoration="underline"; document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "text-decoration:underline;"; } } } function getValueSelect(){ selec = currentValueId; var myRegex2 = new RegExp(/font-size *:[^;]*;/i); var MyValue = document.getElementById("style_select_wysija").value; document.getElementById("name_"+currentValueId).style.fontSize = MyValue; if(document.getElementById("style_"+currentValueId).value.search(myRegex2) != -1){ if(MyValue == ""){ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, ""); }else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value.replace(myRegex2, "font-size:"+MyValue+";"); } }else{ document.getElementById("style_"+currentValueId).value = document.getElementById("style_"+currentValueId).value + "font-size:"+MyValue+";"; } } function initDiv(){ var RegexSize = new RegExp(/font-size *:[^;]*(;)?/gi); var RegexColor = new RegExp(/([^a-z-])color *:[^;]*(;)?/gi); document.getElementById("colorexamplewysijacolor").style.backgroundColor = "#000000"; document.getElementById("colordivwysijacolor").style.display = "none"; spaced = document.getElementById("style_"+currentValueId).value.substr(0,1); if(spaced != " "){ stringToQuery = \' \' + document.getElementById("style_"+currentValueId).value; }else{ stringToQuery = document.getElementById("style_"+currentValueId).value; } NewColor = stringToQuery.match(RegexColor); if(NewColor != null){ NewColor = NewColor[0].match(/:[^;!]*/gi); NewColor = NewColor[0].replace(/(:| )/gi,""); document.getElementById("colorexamplewysijacolor").style.backgroundColor = NewColor; } document.getElementById("U").className = "uelement"; document.getElementById("I").className = "ielement"; document.getElementById("B").className = "belement"; if(document.getElementById("style_"+currentValueId).value.search(/font-weight: *bold(;)?/i) != -1){ document.getElementById("B").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/font-style: *italic(;)?/i) != -1){ document.getElementById("I").className += "selected"; } if(document.getElementById("style_"+currentValueId).value.search(/text-decoration: *underline(;)?/i) != -1){ document.getElementById("U").className += "selected"; } NewSize = stringToQuery.match(RegexSize); document.getElementById("style_select_wysija").options[0].selected = true; if(NewSize != null){ NewSize = NewSize[0].match(/:[^;]*/gi); NewSize = NewSize[0].replace(" ",""); NewSize = NewSize.substr(1); for(var i = 0; i < document.getElementById("style_select_wysija").length; i++){ if(document.getElementById("style_select_wysija").options[i].value == NewSize){ document.getElementById("style_select_wysija").options[i].selected = true; } } } }'; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($script); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = new stdClass(); $infos->test_selection = $app->getUserStateFromRequest($paramBase . ".test_selection", 'test_selection', '', 'string'); $infos->test_group = $app->getUserStateFromRequest($paramBase . ".test_group", 'test_group', '', 'string'); $infos->test_emails = $app->getUserStateFromRequest($paramBase . ".test_emails", 'test_emails', '', 'string'); $acyToolbar = acymailing::get('helper.toolbar'); if (acymailing_isAllowed($config->get('acl_tags_view', 'all'))) { $acyToolbar->popup('tag', JText::_('TAGS'), JURI::base() . "index.php?option=com_acymailing&ctrl=tag&task=tag&tmpl=component&type=news", 780, 550); } $acyToolbar->custom('test', JText::_('SEND_TEST'), 'send', false); $acyToolbar->divider(); $acyToolbar->addButtonOption('apply', JText::_('ACY_APPLY'), 'apply', false); $acyToolbar->save(); $acyToolbar->cancel(); $acyToolbar->divider(); $acyToolbar->help('template', 'templatecreation'); $acyToolbar->setTitle(JText::_('ACY_TEMPLATE'), 'template&task=edit&tempid=' . $tempid); $acyToolbar->display(); $this->assignRef('editor', $editor); $testreceiverType = acymailing_get('type.testreceiver'); $this->assignRef('testreceiverType', $testreceiverType); $this->assignRef('template', $template); $colorBox = acymailing_get('type.color'); $this->assignRef('colorBox', $colorBox); $this->assignRef('infos', $infos); $tabs = acymailing_get('helper.acytabs'); $tabs->setOptions(array('useCookie' => true)); $this->assignRef('tabs', $tabs); }