本文整理汇总了PHP中Contao\BackendTemplate::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendTemplate::setData方法的具体用法?PHP BackendTemplate::setData怎么用?PHP BackendTemplate::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\BackendTemplate
的用法示例。
在下文中一共展示了BackendTemplate::setData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addBackendAdminMenu
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;
}
示例2: sendNewsletter
/**
* 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);
}
}
}
示例3: generateLabel
/**
* 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();
}