本文整理汇总了PHP中EmailTemplate::get方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailTemplate::get方法的具体用法?PHP EmailTemplate::get怎么用?PHP EmailTemplate::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailTemplate
的用法示例。
在下文中一共展示了EmailTemplate::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendLoginDetails
function sendLoginDetails($email)
{
global $sitename;
global $logo;
$query = MYSQL_QUERY("SELECT `Username`,`Password` FROM `ChallengeMembers` WHERE `Email` = '" . $email . "' ") or die(MYSQL_ERROR());
if ($query) {
if (MYSQL_NUM_ROWS($query)) {
while ($row = MYSQL_FETCH_ARRAY($query)) {
$userpassword = $row['Password'];
$username = $row['Username'];
}
/*send email*/
include 'email_class.php';
$em = new EmailTemplate();
$subject = ucfirst($sitename) . " Login Details";
$headers = "From: " . ucwords($sitename) . " <admin@domaindirectory.com> \r\n" . 'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$email_message = $username . ",<br /><br /> Thank you for your interest in joining our challenges.\n\t\t\t\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t\t\t\tThe following are your login data:\n\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\tUsername : <b>" . $username . "</b><br />\n\t\t\t\t\t\t\t\t\tPassword : <b>" . $userpassword . "</b>\n\t\t\t\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t\t\t\tThank you.<br />\n\t\t\t\t\t\t\t\t\t<b>" . $sitename . "</b>";
$emailmessage = $em->get($logo, $sitename, $email_message);
/*first send to guest */
$sentmail = mail($email, $subject, $emailmessage, $headers);
/*end of send email*/
return "OK";
} else {
return $email . "not found in database.";
}
} else {
return "Email not found in database.";
}
}
示例2: sendemailVerification
function sendemailVerification($username, $email, $verification_code)
{
global $sitename;
global $logo;
include 'email_class.php';
$em = new EmailTemplate();
$subject = ucfirst($sitename) . " Registration";
$headers = "From: " . ucwords($sitename) . " <admin@domaindirectory.com> \r\n" . 'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$email_message = $username . ",<br /><br /> Thank you for your interest in joining our challenges.\n\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\tTo verify your account, please click <a href='http://" . $sitename . "/verify.html?code=" . $verification_code . "'>here</a>.\n\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t<b>" . $sitename . "</b>";
$emailmessage = $em->get($logo, $sitename, $email_message);
/*first send to guest */
$sentmail = mail($email, $subject, $emailmessage, $headers);
}
示例3: doSendTestEmail
public function doSendTestEmail()
{
$template = EmailTemplate::get()->byID(filter_input(INPUT_POST, 'EmailTemplateID'));
if (!$template) {
throw new Exception("Template is not found");
}
$emailAddr = $this->getRequest()->postVar('SendTestEmail');
$email = $template->getEmail();
$email->setSampleRequiredObjects();
$email->setTo($emailAddr);
$res = $email->send();
if ($res) {
return 'Test email sent to ' . $emailAddr;
}
return 'Failed to send test to ' . $emailAddr;
}
示例4: SendMail
function SendMail($to, $from, $message, $username, $username_from)
{
global $sitename;
global $logo;
include 'email_class.php';
$em = new EmailTemplate();
$subject = ucfirst($sitename) . " Challenge Sponsorship";
$headers = "From: " . $username_from . " " . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$email_message = "Hi " . $username . ",<br /><br /> " . ucfirst($username_from) . " has submitted sponsorship. And sent the message:\n\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t{$message}\n\t\t\t\t\t\t<br /><br />\n\t\t\t\t\t\t<b>" . $sitename . "</b>";
$emailmessage = $em->get($logo, $sitename, $email_message);
/*first send to guest */
if (mail($to, $subject, $emailmessage, $headers)) {
return true;
} else {
return false;
}
}
示例5: getByCode
/**
* Get an email template by code
*
* @param string $code
* @return EmailTemplate
*/
public static function getByCode($code)
{
$template = EmailTemplate::get()->filter('Code', $code)->first();
if (!$template) {
$template = new EmailTemplate();
$template->Title = $code;
$template->Code = $code;
$template->Content = 'Please replace the content of this email';
$template->write();
}
return $template;
}
示例6: getByCode
/**
* Get an email template by code
*
* @param string $code
* @return EmailTemplate
*/
public static function getByCode($code)
{
$template = EmailTemplate::get()->filter('Code', $code)->first();
// If subsite, fallback to main site email if not defined
if (!$template && class_exists('Subsite') && Subsite::currentSubsiteID()) {
Subsite::$disable_subsite_filter = true;
$template = EmailTemplate::get()->filter('Code', $code)->first();
Subsite::$disable_subsite_filter = false;
}
// In dev mode, create a placeholder email
if (!$template) {
$template = new EmailTemplate();
$template->Title = $code;
$template->Code = $code;
$template->Content = '';
$template->write();
}
return $template;
}
示例7: run
public function run($request)
{
echo 'Run with ?clear=1 to clear empty database before running the task<br/>';
echo 'Run with ?overwrite=soft|hard to overwrite templates that exists in the cms. Soft will replace template if not modified by the user, hard will replace template even if modified by user.<br/>';
echo 'Run with ?templates=xxx,yyy to specify which template should be imported<br/>';
echo 'Run with ?subsite=all|subsiteID to create email templates in all subsites (including main site) or only in the chosen subsite (if a subsite is active, it will be used by default).<br/>';
echo 'Run with ?locales=fr,en to choose which locale to import.<br/>';
echo '<strong>Remember to flush the templates/translations if needed</strong><br/>';
echo '<hr/>';
$overwrite = $request->getVar('overwrite');
$clear = $request->getVar('clear');
$templatesToImport = $request->getVar('templates');
$importToSubsite = $request->getVar('subsite');
$chosenLocales = $request->getVar('locales');
// Normalize argument
if ($overwrite && $overwrite != 'soft' && $overwrite != 'hard') {
$overwrite = 'soft';
}
$subsites = array();
if ($importToSubsite == 'all') {
$subsites = Subsite::get()->map();
} else {
if (is_numeric($importToSubsite)) {
$subsites = array($importToSubsite => Subsite::get()->byID($importToSubsite)->Title);
}
}
if (class_exists('Subsite') && Subsite::currentSubsiteID()) {
DB::alteration_message("Importing to current subsite. Run from main site to import other subsites at once.", "created");
$subsites = array();
}
if (!empty($subsites)) {
DB::alteration_message("Importing to subsites : " . implode(',', array_values($subsites)), "created");
}
if ($templatesToImport) {
$templatesToImport = explode(',', $templatesToImport);
}
if ($clear == 1) {
DB::alteration_message("Clear all email templates", "created");
$emailTemplates = EmailTemplate::get();
foreach ($emailTemplates as $emailTemplate) {
$emailTemplate->delete();
}
}
$emailTemplateSingl = singleton('EmailTemplate');
$ignoredModules = self::config()->ignored_modules;
if (!is_array($ignoredModules)) {
$ignoredModules = array();
}
$locales = null;
if (class_exists('Fluent') && Fluent::locale_names()) {
if ($emailTemplateSingl->hasExtension('FluentExtension')) {
$locales = array_keys(Fluent::locale_names());
if ($chosenLocales) {
$arr = explode(',', $chosenLocales);
$locales = array();
foreach ($arr as $a) {
if (strlen($a) == 2) {
$a = i18n::get_locale_from_lang($a);
}
$locales[] = $a;
}
}
}
}
$defaultLocale = i18n::get_locale();
$templates = SS_TemplateLoader::instance()->getManifest()->getTemplates();
foreach ($templates as $t) {
$isOverwritten = false;
// Emails in mysite/email are not properly marked as emails
if (isset($t['mysite']) && isset($t['mysite']['email'])) {
$t['email'] = $t['mysite']['email'];
}
// Should be in the /email folder
if (!isset($t['email'])) {
continue;
}
$filePath = $t['email'];
$fileName = basename($filePath, '.ss');
// Should end with *Email
if (!preg_match('/Email$/', $fileName)) {
continue;
}
$relativeFilePath = str_replace(Director::baseFolder(), '', $filePath);
$relativeFilePathParts = explode('/', trim($relativeFilePath, '/'));
// Group by module
$module = array_shift($relativeFilePathParts);
// Ignore some modules
if (in_array($module, $ignoredModules)) {
continue;
}
array_shift($relativeFilePathParts);
// remove /templates part
$templateName = str_replace('.ss', '', implode('/', $relativeFilePathParts));
$templateTitle = basename($templateName);
// Create a default code from template name
$code = strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $fileName));
$code = preg_replace('/-email$/', '', $code);
if (!empty($templatesToImport) && !in_array($code, $templatesToImport)) {
DB::alteration_message("Template with code <b>{$code}</b> was ignored.", "repaired");
continue;
//.........这里部分代码省略.........
示例8: run
public function run($request)
{
echo 'Run with ?clear=1 to clear empty database before running the task<br/>';
echo 'Run with ?overwrite=1 to overwrite templates that exists in the cms<br/>';
echo 'Run with ?templates=xxx,yyy to specify which template should be imported<br/>';
echo 'Run with ?subsite=1 to create email templates in all subsites as well. Overwriting is based on main site.<br/>';
echo '<hr/>';
$overwrite = $request->getVar('overwrite');
$clear = $request->getVar('clear');
$templatesToImport = $request->getVar('templates');
$importToSubsite = $request->getVar('subsite');
$subsites = array();
if ($importToSubsite) {
$subsites = Subsite::get()->map();
}
if ($templatesToImport) {
$templatesToImport = explode(',', $templatesToImport);
}
if ($clear == 1) {
echo '<strong>Clear all email templates</strong><br/>';
$emailTemplates = EmailTemplate::get();
foreach ($emailTemplates as $emailTemplate) {
$emailTemplate->delete();
}
}
$o = singleton('EmailTemplate');
$ignoredModules = self::config()->ignored_modules;
if (!is_array($ignoredModules)) {
$ignoredModules = array();
}
$locales = null;
if (class_exists('Fluent') && Fluent::locale_names()) {
if ($o->hasExtension('FluentExtension')) {
$locales = array_keys(Fluent::locale_names());
}
}
$defaultLocale = i18n::get_locale();
$templates = SS_TemplateLoader::instance()->getManifest()->getTemplates();
foreach ($templates as $t) {
$isOverwritten = false;
// Emails in mysite/email are not properly marked as emails
if (isset($t['mysite']) && isset($t['mysite']['email'])) {
$t['email'] = $t['mysite']['email'];
}
// Should be in the /email folder
if (!isset($t['email'])) {
continue;
}
$filePath = $t['email'];
$fileName = basename($filePath, '.ss');
// Should end with *Email
if (!preg_match('/Email$/', $fileName)) {
continue;
}
$relativeFilePath = str_replace(Director::baseFolder(), '', $filePath);
$relativeFilePathParts = explode('/', trim($relativeFilePath, '/'));
// Group by module
$module = array_shift($relativeFilePathParts);
// Ignore some modules
if (in_array($module, $ignoredModules)) {
continue;
}
array_shift($relativeFilePathParts);
// remove /templates part
$templateName = str_replace('.ss', '', implode('/', $relativeFilePathParts));
$templateTitle = basename($templateName);
// Create a default code from template name
$code = strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $fileName));
$code = preg_replace('/-email$/', '', $code);
if (!empty($templatesToImport) && !in_array($code, $templatesToImport)) {
echo "<div style='color:blue'>Template with code '{$code}' was ignored.</div>";
continue;
}
$emailTemplate = EmailTemplate::get()->filter('Code', $code)->first();
if (!$overwrite && $emailTemplate) {
echo "<div style='color:blue'>Template with code '{$code}' already exists.</div>";
continue;
}
// Create a default title from code
$title = explode('-', $code);
$title = array_map(function ($item) {
return ucfirst($item);
}, $title);
$title = implode(' ', $title);
// Get content of the email
$content = file_get_contents($filePath);
// Analyze content to find incompatibilities
$errors = array();
if (strpos($content, '<% with') !== false) {
$errors[] = 'Replace "with" blocks by plain calls to the variable';
}
if (strpos($content, '<% if') !== false) {
$errors[] = 'If/else logic is not supported. Please create one template by use case or abstract logic into the model';
}
if (strpos($content, '<% loop') !== false) {
$errors[] = 'Loops are not supported. Please create a helper method on the model to render the loop';
}
if (strpos($content, '<% sprintf') !== false) {
$errors[] = 'You should not use sprintf to escape content, please use plain _t calls';
}
//.........这里部分代码省略.........