本文整理汇总了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;
}