| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | private $logo = ''; |
| 19 | 19 | |
| 20 | 20 | public function addBlock($type, $content, $options = []) |
| 21 | 21 | { |
| 22 | - if($content) { | |
| 22 | + if ($content) { | |
| 23 | 23 | $this->blocks[] = [ |
| 24 | 24 | 'type' => $type, |
| 25 | 25 | 'content' => $content, |
| 26 | 26 | 'options' => $options |
| @@ -74,36 +74,40 @@ | ||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if ($block['type'] == 'button') { |
| 77 | 77 | return (string)App::make('view')->make('email.Default._button', [ |
| 78 | - 'link' => Arr::get($block['options'], 'link'), | |
| 79 | - 'btnText' => $block['content'] | |
| 78 | + 'link' => Arr::get($block['options'], 'link'), | |
| 79 | + 'btnText' => $block['content'], | |
| 80 | + 'linkColor' => Utility::getThemeColor(), | |
| 81 | + 'btnTextColor' => Utility::getThemeColor('theme_button_text') | |
| 80 | 82 | ]); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | 85 | if ($block['type'] == 'boxed_content') { |
| 84 | 86 | return (string)App::make('view')->make('email.Default._user_box_content', [ |
| 85 | - 'user_name' => $block['options']['user']->display_name, | |
| 86 | - 'user_avatar' => $block['options']['user']->photo, | |
| 87 | + 'user_name' => $block['options']['user']->getPublicDisplayName(), | |
| 88 | + 'user_avatar' => !(empty($block['options']['user']->xprofile->avatar)) ? $block['options']['user']->xprofile->avatar : $block['options']['user']->photo, | |
| 87 | 89 | 'content' => $block['content'], |
| 88 | 90 | 'permalink' => $block['options']['permalink'], |
| 89 | - 'post_content' => $block['options']['post_content'] | |
| 91 | + 'post_content' => $block['options']['post_content'], | |
| 92 | + 'linkColor' => Utility::getThemeColor() | |
| 90 | 93 | ]); |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | 96 | if ($block['type'] == 'post_boxed_content') { |
| 94 | 97 | return (string)App::make('view')->make('email.Default._user_post_content', [ |
| 95 | - 'user_name' => $block['options']['user']->display_name, | |
| 96 | - 'user_avatar' => $block['options']['user']->photo, | |
| 98 | + 'user_name' => $block['options']['user']->getPublicDisplayName(), | |
| 99 | + 'user_avatar' => !(empty($block['options']['user']->xprofile->avatar)) ? $block['options']['user']->xprofile->avatar : $block['options']['user']->photo, | |
| 97 | 100 | 'content' => $block['content'], |
| 98 | 101 | 'title' => Arr::get($block['options'], 'title'), |
| 99 | 102 | 'permalink' => $block['options']['permalink'], |
| 100 | - 'space_name' => $block['options']['space_name'] | |
| 103 | + 'space_name' => $block['options']['space_name'], | |
| 104 | + 'linkColor' => Utility::getThemeColor() | |
| 101 | 105 | ]); |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | 108 | if ($block['type'] == 'html_content') { |
| 105 | - return $block['content']; | |
| 109 | + return (string)$block['content']; | |
| 106 | 110 | } |
| 107 | 111 | |
| 108 | 112 | return $block['content']; |
| 109 | 113 | } |
| @@ -109,12 +113,25 @@ | ||
| 109 | 113 | } |
| 110 | 114 | |
| 111 | 115 | public function setLogo($logo) |
| 112 | 116 | { |
| 113 | - $this->logo = $logo; | |
| 117 | + if ($logo) { | |
| 118 | + $this->logo = $logo; | |
| 119 | + } | |
| 120 | + | |
| 114 | 121 | return $this; |
| 115 | 122 | } |
| 116 | 123 | |
| 124 | + public function setDefaultLogo() | |
| 125 | + { | |
| 126 | + $emailSettings = Utility::getEmailNotificationSettings(); | |
| 127 | + if (!empty($emailSettings['logo'])) { | |
| 128 | + $this->logo = $emailSettings['logo']; | |
| 129 | + } | |
| 130 | + | |
| 131 | + return $this; | |
| 132 | + } | |
| 133 | + | |
| 117 | 134 | public function addFooterLine($type, $line) |
| 118 | 135 | { |
| 119 | 136 | $this->footerBlocks[] = [ |
| 120 | 137 | 'type' => $type, |
| @@ -130,9 +147,10 @@ | ||
| 130 | 147 | $footerTextHtml = Arr::get($settings, 'email_footer_rendered', ''); |
| 131 | 148 | |
| 132 | 149 | if (!$footerTextHtml) { |
| 133 | 150 | if ($settings['disable_powered_by'] == 'no') { |
| 134 | - $poweredBy = '<a href="https://fluentcommunity.com/discount-deal/?utm_campaign=email&utm_source=footer&utm_medium=email" target="_blank" style="font-size: 12px; margin: 10px 0; text-decoration: none;">Powered by FluentCommunity</a>'; | |
| 151 | + $utmParams = ['utm_campaign' => 'email', 'utm_source' => 'footer', 'utm_medium' => 'email']; | |
| 152 | + $poweredBy = '<a href="' . Utility::getProductUrl(true, $utmParams) . '" target="_blank" style="font-size: 12px; margin: 15px 0; display: block; text-decoration: none;color: #9a9ea6;">Powered by FluentCommunity</a>'; | |
| 135 | 153 | $this->addFooterLine('paragraph', $poweredBy); |
| 136 | 154 | } |
| 137 | 155 | return $this; |
| 138 | 156 | } |
| @@ -138,10 +156,12 @@ | ||
| 138 | 156 | } |
| 139 | 157 | |
| 140 | 158 | $generalSettings = Helper::generalSettings(); |
| 141 | 159 | |
| 160 | + $themeColor = Utility::getThemeColor(); | |
| 161 | + | |
| 142 | 162 | $replaces = [ |
| 143 | - '{{site_name_with_url}}' => '<a target="_blank" href="' . Helper::baseUrl('/') . '">' . Arr::get($generalSettings, 'site_title') . '</a>', | |
| 163 | + '{{site_name_with_url}}' => '<a target="_blank" href="' . Helper::baseUrl('/') . '" style="color: ' . esc_attr($themeColor) . '; text-decoration: none;">' . Arr::get($generalSettings, 'site_title') . '</a>', | |
| 144 | 164 | '{{site_name}}' => Arr::get($generalSettings, 'site_title') |
| 145 | 165 | ]; |
| 146 | 166 | |
| 147 | 167 | $footerTextHtml = str_replace(array_keys($replaces), array_values($replaces), $footerTextHtml); |
| @@ -146,9 +166,9 @@ | ||
| 146 | 166 | |
| 147 | 167 | $footerTextHtml = str_replace(array_keys($replaces), array_values($replaces), $footerTextHtml); |
| 148 | 168 | |
| 149 | 169 | // find pattern like this: {{manage_email_notification_url|Manage Your Email Notifications Preference}} |
| 150 | - $footerTextHtml = preg_replace_callback('/{{(.*?)\|(.*?)}}/', function ($matches) use ($withPlaceHolder) { | |
| 170 | + $footerTextHtml = preg_replace_callback('/{{(.*?)\|(.*?)}}/', function ($matches) use ($withPlaceHolder, $themeColor) { | |
| 151 | 171 | $match1 = $matches[1]; |
| 152 | 172 | if ($match1 != 'manage_email_notification_url') { |
| 153 | 173 | return $matches[0]; |
| 154 | 174 | } |
| @@ -159,15 +179,16 @@ | ||
| 159 | 179 | $url = Helper::baseUrl('fcom_route?route=user_notification_settings&auth=yes'); |
| 160 | 180 | } |
| 161 | 181 | |
| 162 | 182 | $text = $matches[2]; |
| 163 | - return '<a target="_blank" rel="noopenner" href="' . $url . '">' . $text . '</a>'; | |
| 183 | + return '<a target="_blank" rel="noopener noreferrer" style="color: ' . esc_attr($themeColor) . '; text-decoration: underline;" href="' . $url . '">' . $text . '</a>'; | |
| 164 | 184 | }, $footerTextHtml); |
| 165 | 185 | |
| 166 | 186 | $this->addFooterLine('paragraph', $footerTextHtml); |
| 167 | 187 | |
| 168 | 188 | if ($settings['disable_powered_by'] == 'no') { |
| 169 | - $poweredBy = '<p class="powered_by"><a href="https://fluentcommunity.com/discount-deal/?utm_campaign=email&utm_source=footer&utm_medium=email" target="_blank" style="font-size: 12px; text-decoration: none;">Powered by FluentCommunity</a></p>'; | |
| 189 | + $utmParams = ['utm_campaign' => 'email', 'utm_source' => 'footer', 'utm_medium' => 'email']; | |
| 190 | + $poweredBy = '<p style="margin-top: 10px;" class="powered_by"><a href="' . Utility::getProductUrl(true, $utmParams) . '" target="_blank" style="font-size: 12px; margin: 15px 0; text-decoration: none;color: #9a9ea6; display: block;">Powered by FluentCommunity</a></p>'; | |
| 170 | 191 | $this->addFooterLine('paragraph', $poweredBy); |
| 171 | 192 | } |
| 172 | 193 | |
| 173 | 194 | return $this; |
| @@ -195,13 +216,23 @@ | ||
| 195 | 216 | } |
| 196 | 217 | |
| 197 | 218 | $data['footerLines'] = $footerLines; |
| 198 | 219 | |
| 220 | + if ($this->headingBlocks) { | |
| 221 | + $data['headingContent'] = $this->complileHeadingBlocks(); | |
| 222 | + } | |
| 199 | 223 | |
| 200 | - if($this->headingBlocks) { | |
| 201 | - $data['headingContent'] = $this->complileHeadingBlocks(); | |
| 224 | + $html = (string)App::make('view')->make('email.template', $data); | |
| 225 | + | |
| 226 | + // Inline the <head><style> rules onto each element so they survive clients and | |
| 227 | + // log viewers that strip the document head (Outlook, FluentSMTP's DOMPurify | |
| 228 | + // preview). @media/:hover rules can't be inlined and are kept in a <style> tag. | |
| 229 | + try { | |
| 230 | + $html = (new Emogrifier\Emogrifier($html))->emogrify(); | |
| 231 | + } catch (\Throwable $e) { | |
| 232 | + // Fall back to the un-inlined HTML; the <head><style> still covers Gmail. | |
| 202 | 233 | } |
| 203 | 234 | |
| 204 | - return (string)App::make('view')->make('email.template', $data); | |
| 235 | + return $html; | |
| 205 | 236 | } |
| 206 | 237 | |
| 207 | 238 | } |