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 = EmailLayout::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 index() { /* @todo Remove line if year >= 2015 */ if (!\System\Models\EmailLayout::whereCode('default')->count()) { \Eloquent::unguard(); with(new \System\Database\Seeds\SeedSetupEmailLayouts())->run(); } EmailTemplate::syncAll(); $this->getClassExtension('Backend.Behaviors.ListController')->index(); $this->bodyClass = null; }
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 }} </style> </head> <body> {{ message }} </body> </html>'; $text = '{{message}}'; EmailLayout::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 }} </style> </head> <body> {{ message }} <hr /> <p>This is an automatic message. Please do not reply to it.</p> </body> </html>'; $text = '{{message}} --- This is an automatic message. Please do not reply to it. '; EmailLayout::create(['is_locked' => true, 'name' => 'System', 'code' => 'system', 'content_html' => $html, 'content_css' => $css, 'content_text' => $text]); }