Exemplo n.º 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 = \Haste\Util\StringUtil::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 = \Haste\Util\StringUtil::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;
     }
 }
 /**
  * Returns a MessageDraft
  * @param   Message
  * @param   array
  * @param   string
  * @return  MessageDraftInterface|null (if no draft could be found)
  */
 public function createDraft(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 null;
     }
     return new PostmarkMessageDraft($objMessage, $objLanguage, $arrTokens);
 }
 /**
  * Modifies the palette for the queue gateway so it takes the one from the
  * target gateway
  *
  * @param \DataContainer $dc
  */
 public function modifyPalette(\DataContainer $dc)
 {
     if (\Input::get('act') != 'edit') {
         return;
     }
     $language = Language::findByPk($dc->id);
     $message = $language->getRelated('pid');
     $gateway = $message->getRelated('gateway');
     if ($gateway !== null && $gateway->type == 'queue') {
         $targetGateway = Gateway::findByPk($gateway->queue_targetGateway);
         $GLOBALS['TL_DCA']['tl_nc_language']['palettes']['queue'] = $GLOBALS['TL_DCA']['tl_nc_language']['palettes'][$targetGateway->type];
     }
 }