コード例 #1
0
 /**
  * Create file
  *
  * @param   Message
  * @param   array
  * @param   string
  * @return  bool
  */
 public function send(Message $objMessage, array $arrTokens, $strLanguage = '')
 {
     if ($strLanguage == '') {
         $strLanguage = $GLOBALS['TL_LANGUAGE'];
     }
     if (($objLanguage = Language::findByMessageAndLanguageOrFallback($objMessage, $strLanguage)) === null) {
         \System::log(sprintf('Could not find matching language or fallback for message ID "%s" and language "%s".', $objMessage->id, $strLanguage), __METHOD__, TL_ERROR);
         return false;
     }
     $strFileName = String::recursiveReplaceTokensAndTags($objLanguage->file_name, $arrTokens, String::NO_TAGS | String::NO_BREAKS);
     // Escape quotes and line breaks for CSV files
     if ($this->objModel->file_type == 'csv') {
         array_walk($arrTokens, function (&$varValue) {
             $varValue = str_replace(array('"', "\r\n", "\r"), array('""', "\n", "\n"), $varValue);
         });
     }
     // Preserve all tags here as this is pretty useful in XML :-)
     $strContent = String::recursiveReplaceTokensAndTags($objLanguage->file_content, $arrTokens);
     try {
         return $this->save($strFileName, $strContent, (string) $objLanguage->file_storage_mode);
     } catch (\Exception $e) {
         \System::log('Notification Center gateway error: ' . $e->getMessage(), __METHOD__, TL_ERROR);
         return false;
     }
 }
コード例 #2
0
 /**
  * Returns the paths to attachments as an array
  * @return  array
  */
 public function getAttachments()
 {
     // Token attachments
     $arrAttachments = String::getTokenAttachments($this->objLanguage->attachment_tokens, $this->arrTokens);
     // Add static attachments
     $arrStaticAttachments = deserialize($this->objLanguage->attachments, true);
     if (!empty($arrStaticAttachments)) {
         $objFiles = \FilesModel::findMultipleByUuids($arrStaticAttachments);
         if ($objFiles === null) {
             return $arrAttachments;
         }
         while ($objFiles->next()) {
             $arrAttachments[] = TL_ROOT . '/' . $objFiles->path;
         }
     }
     return $arrAttachments;
 }
コード例 #3
0
 /**
  * @deprecated Use String::compileRecipients()
  */
 protected function compileRecipients($strRecipients, $arrTokens)
 {
     return String::compileRecipients($strRecipients, $arrTokens);
 }
コード例 #4
0
 /**
  * Generate CC or BCC recipients from comma separated string
  *
  * @param string $strRecipients
  * @param array  $arrTokens
  *
  * @return array
  */
 public static function compileRecipients($strRecipients, $arrTokens)
 {
     // Replaces tokens first so that tokens can contain a list of recipients.
     $strRecipients = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strRecipients, $arrTokens, static::NO_TAGS | static::NO_BREAKS);
     $arrRecipients = array();
     foreach ((array) trimsplit(',', $strRecipients) as $strAddress) {
         if ($strAddress != '') {
             list($strName, $strEmail) = \String::splitFriendlyEmail($strAddress);
             // Address could become empty through invalid insert tag
             if ($strAddress == '' || !\Validator::isEmail($strEmail)) {
                 continue;
             }
             $arrRecipients[] = $strAddress;
         }
     }
     return $arrRecipients;
 }