本文整理匯總了PHP中XLite\Core\Translation::setTmpMailTranslationCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translation::setTmpMailTranslationCode方法的具體用法?PHP Translation::setTmpMailTranslationCode怎麽用?PHP Translation::setTmpMailTranslationCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XLite\Core\Translation
的用法示例。
在下文中一共展示了Translation::setTmpMailTranslationCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: compose
/**
* Composes mail message.
*
* @param string $from The sender email address
* @param string $to The email address to send mail to
* @param string $dir The directiry there mail parts template located
* @param array $customHeaders The headers you want to add/replace to. OPTIONAL
* @param string $interface Interface to use for mail OPTIONAL
* @param string $languageCode Language code OPTIONAL
*
* @return void
*/
public function compose($from, $to, $dir, array $customHeaders = array(), $interface = \XLite::CUSTOMER_INTERFACE, $languageCode = '')
{
static::$composeRunned = true;
if ('' === $languageCode && \XLite::ADMIN_INTERFACE === $interface && !\XLite::isAdminZone()) {
$languageCode = \XLite\Core\Config::getInstance()->General->default_admin_language;
}
\XLite\Core\Translation::setTmpMailTranslationCode($languageCode);
// initialize internal properties
$this->set('from', $from);
$this->set('to', $to);
$this->set('customHeaders', $customHeaders);
$this->set('dir', $dir);
$subject = $this->compile($this->get('subjectTemplate'), $interface);
$subject = \XLite\Core\Mailer::getInstance()->populateVariables($subject);
$this->set('subject', $subject);
$this->set('body', $this->compile($this->get('layoutTemplate'), $interface));
$body = $this->get('body');
$body = \XLite\Core\Mailer::getInstance()->populateVariables($body);
// find all images and fetch them; replace with cid:...
$fname = tempnam(LC_DIR_COMPILE, 'mail');
file_put_contents($fname, $body);
$this->imageParser = new \XLite\Model\MailImageParser();
$this->imageParser->webdir = \XLite::getInstance()->getShopURL('', false);
$this->imageParser->parse($fname);
$this->set('body', $this->imageParser->result);
$this->set('images', $this->imageParser->images);
ob_start();
// Initialize PHPMailer from configuration variables (it should be done once in a script execution)
$this->initMailFromConfig();
// Initialize Mail from inner set of variables.
$this->initMailFromSet();
$output = ob_get_contents();
ob_end_clean();
if ('' !== $output) {
\XLite\Logger::getInstance()->log('Mailer echoed: "' . $output . '". Error: ' . $this->mail->ErrorInfo);
}
// Check if there is any error during mail composition. Log it.
if ($this->mail->isError()) {
\XLite\Logger::getInstance()->log('Compose mail error: ' . $this->mail->ErrorInfo);
}
if (file_exists($fname)) {
unlink($fname);
}
\XLite\Core\Translation::setTmpMailTranslationCode('');
static::$composeRunned = false;
}