public static function syncAll() { $templates = self::make()->listRegisteredTemplates(); $dbTemplates = self::lists('is_custom', 'code'); $newTemplates = array_diff_key($templates, $dbTemplates); /* * Clean up non-customized templates */ foreach ($dbTemplates as $code => $is_custom) { if ($is_custom) { continue; } if (!array_key_exists($code, $templates)) { self::whereCode($code)->delete(); } } /* * Create new templates */ if (count($newTemplates)) { $categories = MailLayout::lists('id', 'code'); } foreach ($newTemplates as $code => $description) { $sections = self::getTemplateSections($code); $layoutCode = array_get($sections, 'settings.layout', 'default'); $template = self::make(); $template->code = $code; $template->description = $description; $template->is_custom = false; $template->layout_id = isset($categories[$layoutCode]) ? $categories[$layoutCode] : null; $template->forceSave(); } }
public function run() { $css = 'a, a:hover { text-decoration: none; color: #0862A2; font-weight: bold; } td, tr, th, table { padding: 0px; margin: 0px; } p { margin: 10px 0; }'; $html = '<html> <head> <style type="text/css" media="screen"> {{ css|raw }} </style> </head> <body> {{ content|raw }} </body> </html>'; $text = '{{ content|raw }}'; MailLayout::create(['is_locked' => false, 'name' => 'MRC default', 'code' => 'mrc_default', 'content_html' => $html, 'content_css' => $css, 'content_text' => $text]); }
public function index() { /* @todo Remove line if year >= 2015 */ if (!\System\Models\MailLayout::whereCode('default')->count()) { \Eloquent::unguard(); with(new \System\Database\Seeds\SeedSetupMailLayouts())->run(); } MailTemplate::syncAll(); $this->asExtension('ListController')->index(); $this->bodyClass = 'compact-container'; }
public function up() { foreach (MailLayout::all() as $layout) { try { $layout->content_html = preg_replace("/({{\\s*message\\s*[|]raw\\s*}})/i", "{{ content|raw }}", $layout->content_html); $layout->content_text = preg_replace("/({{\\s*message\\s*[|]raw\\s*}})/i", "{{ content|raw }}", $layout->content_text); $layout->forceSave(); } catch (Exception $ex) { } } }
public function run() { $css = 'a, a:hover { text-decoration: none; color: #0862A2; font-weight: bold; } td, tr, th, table { padding: 0px; margin: 0px; } p { margin: 10px 0; }'; $html = '<html> <head> <style type="text/css" media="screen"> {{ css|raw }} </style> </head> <body> {{ content|raw }} </body> </html>'; $text = '{{ content|raw }}'; MailLayout::create(['is_locked' => true, 'name' => 'Default', 'code' => 'default', 'content_html' => $html, 'content_css' => $css, 'content_text' => $text]); $html = '<html> <head> <style type="text/css" media="screen"> {{ css|raw }} </style> </head> <body> {{ content|raw }} <hr /> <p>This is an automatic message. Please do not reply to it.</p> </body> </html>'; $text = '{{ content|raw }} --- This is an automatic message. Please do not reply to it. '; MailLayout::create(['is_locked' => true, 'name' => 'System', 'code' => 'system', 'content_html' => $html, 'content_css' => $css, 'content_text' => $text]); }
public function fillFromView() { $sections = self::getTemplateSections($this->code); $this->content_html = $sections['html']; $this->content_text = $sections['text']; $this->subject = array_get($sections, 'settings.subject', 'No subject'); $layoutCode = array_get($sections, 'settings.layout', 'default'); $this->layout_id = MailLayout::getIdFromCode($layoutCode); }