/** * Add the table tl_theme * * @param \DOMDocument $xml * @param \DOMNode|\DOMElement $tables * @param Database\Result|object $objTheme */ protected function addTableTlTheme(\DOMDocument $xml, \DOMNode $tables, Database\Result $objTheme) { // Add the table $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_theme'); $table = $tables->appendChild($table); // Load the DCA $this->loadDataContainer('tl_theme'); // Get the order fields $objDcaExtractor = \DcaExtractor::getInstance('tl_theme'); $arrOrder = $objDcaExtractor->getOrderFields(); // Add the row $this->addDataRow($xml, $table, $objTheme->row(), $arrOrder); }
/** * Compile the newsletter and send it * * @param Email $objEmail * @param Database\Result|object $objNewsletter * @param array $arrRecipient * @param string $text * @param string $html * @param string $css * * @return string */ protected function sendNewsletter(Email $objEmail, Database\Result $objNewsletter, $arrRecipient, $text, $html, $css = null) { // Prepare the text content $objEmail->text = \StringUtil::parseSimpleTokens($text, $arrRecipient); if (!$objNewsletter->sendText) { // Default template if ($objNewsletter->template == '') { $objNewsletter->template = 'mail_default'; } /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate($objNewsletter->template); $objTemplate->setData($objNewsletter->row()); $objTemplate->title = $objNewsletter->subject; $objTemplate->body = \StringUtil::parseSimpleTokens($html, $arrRecipient); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->recipient = $arrRecipient['email']; // Deprecated since Contao 4.0, to be removed in Contao 5.0 $objTemplate->css = $css; // Parse template $objEmail->html = $objTemplate->parse(); $objEmail->imageDir = TL_ROOT . '/'; } // Deactivate invalid addresses try { $objEmail->sendTo($arrRecipient['email']); } catch (\Swift_RfcComplianceException $e) { $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email']; } // Rejected recipients if ($objEmail->hasFailures()) { $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email']; } // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['sendNewsletter']) && is_array($GLOBALS['TL_HOOKS']['sendNewsletter'])) { foreach ($GLOBALS['TL_HOOKS']['sendNewsletter'] as $callback) { $this->import($callback[0]); $this->{$callback[0]}->{$callback[1]}($objEmail, $objNewsletter, $arrRecipient, $text, $html); } } }
/** * Create a new collection from a database result * * @param Result $objResult The database result object * @param string $strTable The table name * * @return static The model collection */ public static function createFromDbResult(Result $objResult, $strTable) { $arrModels = array(); $strClass = \Model::getClassFromTable($strTable); while ($objResult->next()) { /** @var Model $strClass */ $objModel = \Model\Registry::getInstance()->fetch($strTable, $objResult->{$strClass::getPk()}); if ($objModel !== null) { $objModel->mergeRow($objResult->row()); $arrModels[] = $objModel; } else { $arrModels[] = new $strClass($objResult); } } return new static($arrModels, $strTable); }