本文整理汇总了PHP中Locale::getEmailTemplateFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getEmailTemplateFilename方法的具体用法?PHP Locale::getEmailTemplateFilename怎么用?PHP Locale::getEmailTemplateFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::getEmailTemplateFilename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isLocaleFile
function isLocaleFile($locale, $filename)
{
if (in_array($filename, TranslatorAction::getLocaleFiles($locale))) {
return true;
}
if (in_array($filename, TranslatorAction::getMiscLocaleFiles($locale))) {
return true;
}
if ($filename == Locale::getEmailTemplateFilename($locale)) {
return true;
}
return false;
}
示例2: saveEmail
function saveEmail($args)
{
list($plugin) = TranslatorHandler::validate();
TranslatorHandler::setupTemplate();
$locale = array_shift($args);
if (!Locale::isLocaleValid($locale)) {
Request::redirect(null, null, 'index');
}
$emails = TranslatorAction::getEmailTemplates($locale);
$referenceEmails = TranslatorAction::getEmailTemplates(MASTER_LOCALE);
$emailKey = array_shift($args);
if (!in_array($emailKey, array_keys($referenceEmails)) && !in_array($emailKey, array_keys($emails))) {
Request::redirect(null, null, 'index');
}
import('i18n.EditableEmailFile');
$file =& new EditableEmailFile($locale, Locale::getEmailTemplateFilename($locale));
$subject = TranslatorHandler::correctCr(Request::getUserVar('subject'));
$body = TranslatorHandler::correctCr(Request::getUserVar('body'));
$description = TranslatorHandler::correctCr(Request::getUserVar('description'));
if (!$file->update($emailKey, $subject, $body, $description)) {
$file->insert($emailKey, $subject, $body, $description);
}
$file->write();
if (Request::getUserVar('returnToCheck') == 1) {
Request::redirect(null, null, 'check', $locale);
} else {
Request::redirect(null, null, 'edit', $locale);
}
}
示例3: testEmails
/**
* Test the emails in the supplied locale against those in the supplied
* reference locale.
* @param $locale string
* @param $referenceLocale string
* @return array List of errors
*/
function testEmails($locale, $referenceLocale)
{
$errors = array();
$xmlParser =& new XMLParser();
$referenceEmails =& $xmlParser->parse(Locale::getEmailTemplateFilename($referenceLocale));
$emails =& $xmlParser->parse(Locale::getEmailTemplateFilename($locale));
$emailsTable =& $emails->getChildByName('table');
$referenceEmailsTable =& $referenceEmails->getChildByName('table');
$matchedReferenceEmails = array();
// Pass 1: For all translated emails, check that they match
// against reference translations.
for ($emailIndex = 0; ($email =& $emailsTable->getChildByName('row', $emailIndex)) !== null; $emailIndex++) {
// Extract the fields from the email to be tested.
$fields = Locale::extractFields($email);
// Locate the reference email and extract its fields.
for ($referenceEmailIndex = 0; ($referenceEmail =& $referenceEmailsTable->getChildByName('row', $referenceEmailIndex)) !== null; $referenceEmailIndex++) {
$referenceFields = Locale::extractFields($referenceEmail);
if ($referenceFields['email_key'] == $fields['email_key']) {
break;
}
}
// Check if a matching reference email was found.
if (!isset($referenceEmail) || $referenceEmail === null) {
$errors[EMAIL_ERROR_EXTRA_EMAIL][] = array('key' => $fields['email_key']);
continue;
}
// We've successfully found a matching reference email.
// Compare it against the translation.
$bodyParams = Locale::getParameterNames($fields['body']);
$referenceBodyParams = Locale::getParameterNames($referenceFields['body']);
$diff = array_diff($bodyParams, $referenceBodyParams);
if (!empty($diff)) {
$errors[EMAIL_ERROR_DIFFERING_PARAMS][] = array('key' => $fields['email_key'], 'mismatch' => $diff);
}
$subjectParams = Locale::getParameterNames($fields['subject']);
$referenceSubjectParams = Locale::getParameterNames($referenceFields['subject']);
$diff = array_diff($subjectParams, $referenceSubjectParams);
if (!empty($diff)) {
$errors[EMAIL_ERROR_DIFFERING_PARAMS][] = array('key' => $fields['email_key'], 'mismatch' => $diff);
}
$matchedReferenceEmails[] = $fields['email_key'];
unset($email);
unset($referenceEmail);
}
// Pass 2: Make sure that there are no missing translations.
for ($referenceEmailIndex = 0; ($referenceEmail =& $referenceEmailsTable->getChildByName('row', $referenceEmailIndex)) !== null; $referenceEmailIndex++) {
// Extract the fields from the email to be tested.
$referenceFields = Locale::extractFields($referenceEmail);
if (!in_array($referenceFields['email_key'], $matchedReferenceEmails)) {
$errors[EMAIL_ERROR_MISSING_EMAIL][] = array('key' => $referenceFields['email_key']);
}
}
return $errors;
}
示例4: deleteEmail
function deleteEmail($args)
{
$this->validate();
$plugin =& $this->plugin;
$this->setupTemplate();
$locale = array_shift($args);
if (!Locale::isLocaleValid($locale)) {
Request::redirect(null, null, null, 'index');
}
$emails = TranslatorAction::getEmailTemplates($locale);
$referenceEmails = TranslatorAction::getEmailTemplates(MASTER_LOCALE);
$emailKey = array_shift($args);
if (!in_array($emailKey, array_keys($emails))) {
Request::redirect(null, null, null, 'index');
}
import('file.EditableEmailFile');
$file = new EditableEmailFile($locale, Locale::getEmailTemplateFilename($locale));
$subject = Request::getUserVar('subject');
$body = Request::getUserVar('body');
$description = Request::getUserVar('description');
if ($file->delete($emailKey)) {
$file->write();
}
Request::redirect(null, null, null, 'edit', $locale, null, 'emails');
}