当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Email_Template类代码示例

本文整理汇总了PHP中Mage_Core_Model_Email_Template的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Email_Template类的具体用法?PHP Mage_Core_Model_Email_Template怎么用?PHP Mage_Core_Model_Email_Template使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mage_Core_Model_Email_Template类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkCodeUsage

 /**
  * Check usage of template code in other templates
  *
  * @param   Mage_Core_Model_Email_Template $template
  * @return  boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_read->select()->from($this->_templateTable, new Zend_Db_Expr('COUNT(template_id)'))->where('template_id!=?', $template->getId())->where('template_code=?', $template->getTemplateCode());
         $countOfCodes = $this->_read->fetchOne($select);
         return $countOfCodes > 0;
     } else {
         return false;
     }
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:16,代码来源:Template.php

示例2: checkCodeUsage

 /**
  * Check usage of template code in other templates
  *
  * @param Mage_Core_Model_Email_Template $template
  * @return boolean
  */
 public function checkCodeUsage(Mage_Core_Model_Email_Template $template)
 {
     if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
         $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), 'COUNT(*)')->where('template_id != :template_id')->where('template_code = :template_code');
         $bind = array('template_id' => $template->getId(), 'template_code' => $template->getTemplateCode());
         $result = $this->_getReadAdapter()->fetchOne($select, $bind);
         if ($result) {
             return true;
         }
     }
     return false;
 }
开发者ID:njaeger,项目名称:magento_github,代码行数:18,代码来源:Template.php

示例3: getAvailableTemplates

 public function getAvailableTemplates($asHash = true)
 {
     $result = array();
     $collection = Mage::getResourceModel('core/email_template_collection')->load();
     $options = $collection->toOptionArray();
     $defOptions = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     // the same as + but to be sure
     foreach ($defOptions as $v) {
         $options[] = $v;
     }
     // convert to hash
     foreach ($options as $v) {
         $result[$v['value']] = $v['label'];
     }
     // sort by names alphabetically
     asort($result);
     if (!$asHash) {
         $options = array();
         foreach ($result as $k => $v) {
             $options[] = array('value' => $k, 'label' => $v);
         }
         $result = $options;
     }
     return $result;
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:25,代码来源:Data.php

示例4: toOptionArray

 public function toOptionArray()
 {
     $options = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     $options[0]['label'] = Mage::helper('aw_hdu3')->__('Do not send');
     $options[0]['value'] = 0;
     return array_merge($options, parent::toOptionArray());
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:7,代码来源:Template.php

示例5: loadByConfigPath

 /**
  * Load template by configuration path. This enables html templates to include other html templates by their
  * system configuration XPATH value
  *
  * @param   string $configPath The path to the config setting that defines which global/template/email/* node
  * should be used to load the email template
  * @return   Mage_Core_Model_Email_Template
  */
 public function loadByConfigPath($configPath)
 {
     $templateId = Mage::getStoreConfig($configPath);
     if (is_numeric($templateId)) {
         // Template was overridden in admin, so load template from database
         $this->load($templateId);
     } else {
         $defaultTemplates = Mage_Core_Model_Email_Template::getDefaultTemplates();
         if (!isset($defaultTemplates[$templateId])) {
             return null;
         }
         $storeId = $this->getDesignConfig()->getStore();
         $data =& $defaultTemplates[$templateId];
         $this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT);
         $localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
         $templateText = Mage::app()->getTranslator()->getTemplateFile($data['file'], 'email', $localeCode);
         $this->setTemplateText($templateText);
         $this->setId($templateId);
     }
     // Templates loaded via the {{template config_path=""}} syntax don't support the subject/vars/styles
     // comment blocks, so strip them out
     $templateText = preg_replace('/<!--@(\\w+)\\s*(.*?)\\s*@-->/us', '', $this->getTemplateText());
     // Remove comment lines
     $templateText = preg_replace('#\\{\\*.*\\*\\}#suU', '', $templateText);
     $this->setTemplateText($templateText);
     return $this;
 }
开发者ID:okite11,项目名称:frames21,代码行数:35,代码来源:Abstract.php

示例6: loadBaseContentsDataProvider

 public function loadBaseContentsDataProvider()
 {
     $data = array();
     $config = Mage::getConfig();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplates() as $row) {
         $data[] = array($config->determineOmittedNamespace($row['@']['module'], true), $row['file']);
     }
     return $data;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:9,代码来源:TemplateFilesTest.php

示例7: getLoadTemplate

 public function getLoadTemplate()
 {
     $templateCode = Mage::app()->getRequest()->getParam('templatecode');
     $defaultTemplates = Mage_Core_Model_Email_Template::getDefaultTemplates();
     if (isset($defaultTemplates[$templateCode])) {
         return $templateCode;
     }
     return false;
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:9,代码来源:Autoload.php

示例8: sendTransactional

 /**
  * Send transactional email to recipient
  *
  * @see Mage_Core_Model_Email_Template::sendTransactional()
  * @param   string $templateId
  * @param   string|array $sender sneder information, can be declared as part of config path
  * @param   string $email recipient email
  * @param   string $name recipient name
  * @param   array $vars varianles which can be used in template
  * @param   int|null $storeId
  * @return  Mage_Core_Model_Email_Template
  */
 public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
 {
     if (!Mage::helper('wfs_disable_emails')->isDisabled($templateId)) {
         return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
     } else {
         $this->setSentSuccess(true);
         return $this;
     }
 }
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:21,代码来源:Template.php

示例9: _beforeToHtml

 /**
  * Collect, sort and set template options
  *
  * @return Mage_Adminhtml_Block_System_Email_Template_Edit
  */
 protected function _beforeToHtml()
 {
     $groupedOptions = array();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray() as $option) {
         $groupedOptions[$option['group']][] = $option;
     }
     ksort($groupedOptions);
     $this->setData('template_options', $groupedOptions);
     return parent::_beforeToHtml();
 }
开发者ID:nemphys,项目名称:magento2,代码行数:15,代码来源:Edit.php

示例10: afterSave

 public function afterSave(Mage_Core_Model_Email_Template $template)
 {
     if (true !== Mage::registry('aitemails_template_save_noaddconfig')) {
         $template_data = $template->getData();
         $this->_addToConfig($template, $template_data['orig_template_code']);
     }
     $oReq = Mage::app()->getFrontController()->getRequest();
     /**
      * saving attachments
      */
     if ($data = $oReq->getPost('aitemails')) {
         if (isset($data['aitattachment'])) {
             $_deleteItems = array();
             foreach ($data['aitattachment'] as $aitattachmentItem) {
                 if ($aitattachmentItem['is_delete'] == '1') {
                     if ($aitattachmentItem['aitattachment_id']) {
                         $_deleteItems[] = $aitattachmentItem['aitattachment_id'];
                     }
                 } else {
                     $aitattachmentModel = Mage::getModel('aitemails/aitattachment');
                     $files = array();
                     if (isset($aitattachmentItem['file'])) {
                         $files = Zend_Json::decode($aitattachmentItem['file']);
                     }
                     $aitattachmentModel->setData($aitattachmentItem)->setAttachmentType($aitattachmentItem['type'])->setTemplateId($template->getId())->setStoreId(0);
                     /* If file is new - its id = 0 */
                     if ($aitattachmentItem['aitattachment_id'] != 0) {
                         $aitattachmentModel->setAttachmentId($aitattachmentItem['aitattachment_id']);
                     }
                     if ($aitattachmentModel->getAttachmentType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
                         $aitattachmentFileName = Mage::helper('downloadable/file')->moveFileFromTmp($aitattachmentModel->getBaseTmpPath(), $aitattachmentModel->getBasePath(), $files);
                         $aitattachmentModel->setAttachmentFile($aitattachmentFileName);
                     }
                     $aitattachmentModel->save();
                 }
             }
             if ($_deleteItems) {
                 Mage::getResourceModel('aitemails/aitattachment')->deleteItems($_deleteItems);
             }
         }
     }
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:42,代码来源:CoreMysql4EmailTemplate.php

示例11: render

 /**
  * Render form element
  *
  * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::render()
  * @param Varien_Data_Form_Element_Abstract $element
  * @return string
  */
 public function render(Varien_Data_Form_Element_Abstract $element)
 {
     $html = $this->_getHeaderHtml($element);
     $emails = Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
     foreach ($emails as $notificationType) {
         if ($notificationType['value']) {
             $html .= $this->_getFieldHtml($element, $notificationType);
         }
     }
     $html .= $this->_getFooterHtml($element);
     return $html;
 }
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:19,代码来源:DisableEmails.php

示例12: addMail

 public function addMail(Mage_Core_Model_Email_Template $mailObject, $email, $name, $variables)
 {
     $emails = array_values((array) $email);
     $names = is_array($name) ? $name : (array) $name;
     $names = array_values($names);
     foreach ($emails as $key => $email) {
         if (!isset($names[$key])) {
             $names[$key] = substr($email, 0, strpos($email, '@'));
         }
     }
     $variables['email'] = reset($emails);
     $variables['name'] = reset($names);
     $mailObject->setUseAbsoluteLinks(true);
     $text = $mailObject->getProcessedTemplate($variables, true);
     if (empty($email)) {
         throw Mage::exception('Codex_Xtest', 'to is empty', Codex_Xtest_Exception::EMPTY_MAIL_RECIPIENT);
     }
     if (empty($text)) {
         throw Mage::exception('Codex_Xtest', 'body is empty', Codex_Xtest_Exception::EMPTY_MAIL_BODY);
     }
     self::$_mailqueue[] = array('variables' => $variables, 'emails' => $emails, 'body' => $text, 'object' => $mailObject);
     return $this;
 }
开发者ID:nhp,项目名称:Xtest,代码行数:23,代码来源:Mailqueue.php

示例13: send

 /**
  * wraps send() method of parent, supplies before and after events, and
  * sends if allowed
  *
  * @param   array|string       $email        E-mail(s)
  * @param   array|string|null  $name         receiver name(s)
  * @param   array              $variables    template variables
  * @see     Mage_Core_Model_Email_Template
  * @return  boolean
  **/
 public function send($email, $name = null, array $variables = array())
 {
     if (!Mage::getStoreConfigFlag('hackathon_mailguard/settings/active')) {
         return parent::send($email, $name, $variables);
     } else {
         $return = FALSE;
         Mage::dispatchEvent('email_template_send_before', array('email' => $this, 'email_to' => $email));
         $validatedEmails = $this->getValidatedEmails();
         if (!$this->getDoNotSend() && !empty($validatedEmails)) {
             $return = parent::send($validatedEmails, $name, $variables);
             // TODO: Change the autogenerated stub
         }
         Mage::dispatchEvent('email_template_send_after', array('email' => $this, 'email_to' => $email));
         return $return;
     }
 }
开发者ID:eniuz,项目名称:MailGuard,代码行数:26,代码来源:Template.php

示例14: toOptionArray

 /**
  * default email templates - all modules
  *
  * @return array
  */
 public function toOptionArray()
 {
     $options = array();
     $idLabel = array();
     foreach (Mage_Core_Model_Email_Template::getDefaultTemplates() as $templateId => $row) {
         if (isset($row['@']) && isset($row['@']['module'])) {
             $module = $row['@']['module'];
         } else {
             $module = 'adminhtml';
         }
         $idLabel[$templateId] = Mage::helper($module)->__($row['label'] . " [module = {$module}]");
     }
     asort($idLabel);
     foreach ($idLabel as $templateId => $label) {
         $options[] = array('value' => $templateId, 'label' => $label);
     }
     return $options;
 }
开发者ID:vdimitrovv,项目名称:dotmailer-magento-extension,代码行数:23,代码来源:Defaultselect.php

示例15: send

 /**
  * Send mail to recipient
  *
  * @param array|string $email - E-mail(s)
  * @param null $name - receiver name(s)
  * @param array $variables - template variables
  * @return boolean
  * @throws Exception
  * @throws Zend_Mail_Exception
  */
 public function send($email, $name = null, array $variables = array())
 {
     /** @var Newsman_Newsletter_Helper_Smtp $_helper */
     $_helper = Mage::helper('newsman_newsletter/smtp');
     if (!$_helper->isEnabled()) {
         return parent::send($email, $name, $variables);
     }
     if (!$this->isValidForSend()) {
         Mage::logException(new Exception('This letter cannot be sent.'));
         // translation is intentionally omitted
         return false;
     }
     $emails = array_values((array) $email);
     $names = is_array($name) ? $name : (array) $name;
     $names = array_values($names);
     foreach ($emails as $key => $email) {
         if (!isset($names[$key])) {
             $names[$key] = substr($email, 0, strpos($email, '@'));
         }
     }
     $variables['email'] = reset($emails);
     $variables['name'] = reset($names);
     $this->setUseAbsoluteLinks(true);
     $text = $this->getProcessedTemplate($variables, true);
     $subject = $this->getProcessedTemplateSubject($variables);
     if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
         /** @var $emailQueue Mage_Core_Model_Email_Queue */
         $emailQueue = $this->getQueue();
         $emailQueue->setMessageBody($text);
         $emailQueue->setMessageParameters(array('subject' => $subject, 'is_plain' => $this->isPlain(), 'from_email' => $this->getSenderEmail(), 'from_name' => $this->getSenderName(), 'reply_to' => $this->getMail()->getReplyTo(), 'return_to' => $this->getMail()->getReturnPath()))->addRecipients($emails, $names, Mage_Core_Model_Email_Queue::EMAIL_TYPE_TO)->addRecipients($this->_bccEmails, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);
         $emailQueue->addMessageToQueue();
         return true;
     }
     ini_set('SMTP', $_helper->getHost());
     ini_set('smtp_port', $_helper->getPort());
     $mail = $this->getMail();
     $config = array('ssl' => $_helper->getSslType(), 'port' => $_helper->getPort(), 'auth' => $_helper->getAuth(), 'username' => $_helper->getUsername(), 'password' => $_helper->getPassword());
     $mailTransport = new Zend_Mail_Transport_Smtp($_helper->getHost(), $config);
     Zend_Mail::setDefaultTransport($mailTransport);
     foreach ($emails as $key => $email) {
         $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
     }
     if ($this->isPlain()) {
         $mail->setBodyText($text);
     } else {
         $mail->setBodyHTML($text);
     }
     $mail->setSubject('=?utf-8?B?' . base64_encode($subject) . '?=');
     $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
     try {
         $mail->send();
         $this->_mail = null;
     } catch (Exception $e) {
         $this->_mail = null;
         Mage::logException($e);
         return false;
     }
     return true;
 }
开发者ID:Newsman,项目名称:Magento-Newsman,代码行数:69,代码来源:Template.php


注:本文中的Mage_Core_Model_Email_Template类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。