public function addBackendAdminMenu($strBuffer, $strTemplate) { if ($strTemplate != 'be_main' || !\BackendUser::getInstance()->isAdmin) { return $strBuffer; } // replace the scripts before processing -> https://code.google.com/archive/p/phpquery/issues/212 $arrScripts = StringUtil::replaceScripts($strBuffer); $objDoc = \phpQuery::newDocumentHTML($arrScripts['content']); $objMenu = new BackendTemplate($this->strTemplate); $arrActions = array(); $arrActiveActions = deserialize(\Config::get('backendAdminMenuActiveActions'), true); foreach (empty($arrActiveActions) ? array_keys(\Config::get('backendAdminMenuActions')) : $arrActiveActions as $strAction) { $arrActionData = $GLOBALS['TL_CONFIG']['backendAdminMenuActions'][$strAction]; $objAction = new BackendTemplate($this->strEntryTemplate); $objAction->setData($arrActionData); // href = callback? if (is_array($arrActionData['href']) || is_callable($arrActionData['href'])) { $strClass = $arrActionData['href'][0]; $strMethod = $arrActionData['href'][1]; $objInstance = \Controller::importStatic($strClass); $objAction->href = $objInstance->{$strMethod}(); } $objAction->class = $strAction; $arrActions[] = $objAction->parse(); } $objMenu->actions = $arrActions; $objDoc['#tmenu']->prepend($objMenu->parse()); $strBuffer = StringUtil::unreplaceScripts($objDoc->htmlOuter(), $arrScripts['scripts']); // avoid double escapings introduced by phpquery :-( $strBuffer = preg_replace('@&([^;]{2,4};)@i', '&$1', $strBuffer); return $strBuffer; }
/** * 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); } } }
/** * Generate the label * * @param array $row * @param string $label * @param DataContainer $dc * @param string $imageAttribute * @param boolean $blnReturnImage * @param boolean $blnProtected * * @return string */ public function generateLabel(array $row, $label = null, DataContainer $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false) { $default = ''; if ($GLOBALS['TL_DCA'][$this->table]['list']['sorting']['mode'] === 4) { $callback = $GLOBALS['TL_DCA'][$this->table]['list']['sorting']['default_child_record_callback']; } else { $callback = $GLOBALS['TL_DCA'][$this->table]['list']['label']['default_label_callback']; } // Get the default label if (is_array($callback)) { $default = System::importStatic($callback[0])->{$callback[1]}($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected); } elseif (is_callable($callback)) { $default = $callback($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected); } $template = new BackendTemplate('be_seo_serp_tests'); $template->setData($this->generateTests($row)); $template->label = $default; // Add assets $GLOBALS['TL_CSS'][] = 'system/modules/seo_serp_preview/assets/css/tests.min.css'; $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/seo_serp_preview/assets/js/tests.min.js'; return $template->parse(); }