/** * Get the data */ private function getData() { // get the record $this->record = (array) BackendMailmotorModel::getMailing($this->id); // get the template record for this mailing $this->template = BackendMailmotorModel::getTemplate($this->record['language'], $this->record['template']); // no item found, throw an exceptions, because somebody is f*****g with our URL if (empty($this->record)) { $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing'); } }
/** * Load the confirmation dialog */ private function loadConfirmationDialog() { // load statistics $groups = BackendMailmotorModel::getGroupsByIds($this->record['groups']); // fetch the campaign $campaign = BackendMailmotorModel::getCampaign($this->record['campaign_id']); // fetch the template $template = BackendMailmotorModel::getTemplate($this->record['language'], $this->record['template']); // declare stats array $stats['recipients'] = count($this->record['recipients']); $stats['mailing'] = $this->record['name']; $stats['label_persons'] = $stats['recipients'] > 1 ? BL::lbl('Persons', 'core') : BL::lbl('Person', 'core'); // campaign was set if (!empty($campaign)) { // set data $stats['message'] = BL::msg('RecipientStatisticsCampaign', $this->getModule()); $stats['campaign'] = $campaign['name']; // assign the recipient statistics variable $this->tpl->assign('recipientStatistics', sprintf($stats['message'], $stats['mailing'], $stats['campaign'], $stats['recipients'], $stats['label_persons'])); } else { // set data $stats['message'] = BL::msg('RecipientStatisticsNoCampaign', $this->getModule()); // assign the recipient statistics variable $this->tpl->assign('recipientStatistics', sprintf($stats['message'], $stats['mailing'], $stats['recipients'], $stats['label_persons'])); } // add comma separator to groups if (!empty($groups)) { // fetch the last key in this array $lastRecord = end($groups); // loop the groups foreach ($groups as $key => &$group) { // add comma field to the groups if this is not the last item if ($lastRecord['id'] != $key) { $group['comma'] = true; } } } // assign the groups to the template $this->tpl->assign('groups', $groups); // assign the template language $this->tpl->assign('templateLanguage', SpoonFilter::ucfirst(BL::lbl(strtoupper($template['language'])))); // get the price settings $pricePerEmail = BackendModel::getModuleSetting($this->getModule(), 'price_per_email'); $pricePerCampaign = BackendModel::getModuleSetting($this->getModule(), 'price_per_campaign'); // parse the price total $this->tpl->assign('price', $stats['recipients'] * $pricePerEmail + $pricePerCampaign); }
/** * Returns the fully parsed e-mail content * * @return string * @param string $template The template to use. * @param string $contentHTML The content. * @param string $fullContentHTML The full content. */ private function getEmailContent($template, $contentHTML, $fullContentHTML) { // require the CSSToInlineStyles class require 'external/css_to_inline_styles.php'; // fetch the template contents for this mailing $template = BackendMailmotorModel::getTemplate($this->mailing['language'], $template); // template content is empty if (!isset($template['content'])) { $this->output(self::ERROR, array('mailing_id' => $this->mailing['id'], 'error' => true), BL::err('TemplateDoesNotExist', $this->getModule())); } // remove TinyMCE $fullContentHTML = preg_replace('/<!-- tinymce -->.*?<!-- \\/tinymce -->/is', $contentHTML, $fullContentHTML); // replace bracketed entities with their proper counterpart $fullContentHTML = preg_replace('/\\[ent=(.*?)]/', '&${1};', $fullContentHTML); // add Google UTM parameters to all anchors $fullContentHTML = $this->addUTMParameters($fullContentHTML); // search values $search[] = '{$siteURL}'; $search[] = '"'; $search[] = 'src="/'; // replace values $replace[] = SITE_URL; $replace[] = '"'; $replace[] = 'src="' . SITE_URL . '/'; // replace some variables $fullContentHTML = str_replace($search, $replace, $fullContentHTML); // set CSS object $css = new CSSToInlineStyles($fullContentHTML, $template['css']); $fullContentHTML = $css->convert(); // return the content return $fullContentHTML; }