本文整理汇总了PHP中BackendTemplate::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendTemplate::setData方法的具体用法?PHP BackendTemplate::setData怎么用?PHP BackendTemplate::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackendTemplate
的用法示例。
在下文中一共展示了BackendTemplate::setData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_listgrid_news');
$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD'][$this->type][0]) . ' ###';
$objTemplate->setData($this->objModel->row());
if ($this->size = !'') {
$arrImageSizes = \System::getImageSizes();
$arrSize = deserialize($this->objModel->size);
if (isset($arrSize[2]) && isset($arrImageSizes['image_sizes'][$arrSize[2]])) {
$objTemplate->imgSize = $arrImageSizes['image_sizes'][$arrSize[2]];
}
}
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
return parent::generate();
}
示例2: generateRow
/**
* Generate the row.
*
* @param array $row Row.
*
* @return string
*/
public function generateRow($row)
{
try {
$entityId = EntityId::fromString($row['entityId']);
$manager = $this->getServiceProvider()->getManager($entityId->getProviderName());
$entity = $this->getServiceProvider()->getEntityManager()->getRepository($entityId->getProviderName())->find($entityId->getIdentifier());
$workflow = $manager->getWorkflow($entityId, $entity);
if ($workflow) {
$row['workflowName'] = $workflow->getLabel();
$row['transitionName'] = $workflow->getTransition($row['transitionName'])->getLabel();
$row['stepName'] = $workflow->getStep($row['stepName'])->getLabel();
}
} catch (\Exception $e) {
// Catch exception here so if the definition has changes no error is thrown.
}
$row['success'] = $this->translate($row['success'] ? 'yes' : 'no', array(), 'MSC');
$template = new \BackendTemplate('be_workflow_state_row');
$template->setData($row);
if (is_numeric($row['reachedAt'])) {
$template->reachedAt = \Date::parse(\Config::get('datimFormat'), $row['reachedAt']);
}
return $template->parse();
}
示例3: renderTemplate
/**
* Render the template.
*
* @param array $params Optional params being rendered.
*
* @return string
*/
protected function renderTemplate($params = array())
{
$template = new \BackendTemplate();
$template->setData($params);
$template->item = $this->item;
$template->workflow = $this->workflow;
return $template->parse();
}
示例4: edit
/**
* Generate the view for edit
*
* @return string
*/
public function edit()
{
// Load basic informations
$this->checkLanguage();
$this->loadCurrentModel();
// Get all selectors
$this->arrStack[] = $this->getDC()->getSubpalettesDefinition();
$this->calculateSelectors($this->arrStack[0]);
$this->parseRootPalette();
include TL_ROOT . '/system/config/languages.php';
// ToDo: What is this $languages[$this->strCurrentLanguage];
$objTemplate = new BackendTemplate('dcbe_general_edit');
$objTemplate->setData(array('fieldsets' => $this->generateFieldsets('dcbe_general_field', array()), 'oldBE' => $GLOBALS['TL_CONFIG']['oldBeTheme'], 'versions' => $this->getDC()->getDataProvider()->getVersions($this->getDC()->getId()), 'language' => $this->objLanguagesSupported, 'subHeadline' => sprintf($GLOBALS['TL_LANG']['MSC']['editRecord'], $this->getDC()->getId() ? 'ID ' . $this->getDC()->getId() : ''), 'languageHeadline' => strlen($this->strCurrentLanguage) != 0 ? $langsNative[$this->strCurrentLanguage] : '', 'table' => $this->getDC()->getTable(), 'enctype' => $this->getDC()->isUploadable() ? 'multipart/form-data' : 'application/x-www-form-urlencoded', 'error' => $this->noReload, 'buttons' => $this->getDC()->getButtonsDefinition(), 'buttonLables' => $this->getDC()->getButtonLabels(), 'noReload' => $this->getDC()->isNoReload()));
return $objTemplate->parse();
}
示例5: handleView
/**
* Handle view.
*
* @param ViewEvent $event The view event.
*
* @return void
*/
public function handleView(ViewEvent $event)
{
if (DcGeneralViews::CLIPBOARD !== $event->getViewName()) {
return;
}
$environment = $event->getEnvironment();
$input = $environment->getInputProvider();
$clipboard = $environment->getClipboard();
$eventDispatcher = $environment->getEventDispatcher();
$basicDefinition = $environment->getDataDefinition()->getBasicDefinition();
$modelProviderName = $basicDefinition->getDataProvider();
$parentProviderName = $basicDefinition->getParentDataProvider();
$filter = new Filter();
$filter->andModelIsFromProvider($modelProviderName);
if ($parentProviderName) {
$filter->andParentIsFromProvider($parentProviderName);
} else {
$filter->andHasNoParent();
}
$options = array();
foreach ($clipboard->fetch($filter) as $item) {
$modelId = $item->getModelId();
$dataProvider = $environment->getDataProvider($item->getDataProviderName());
if ($modelId) {
$config = $dataProvider->getEmptyConfig();
$config->setId($modelId->getId());
$model = $dataProvider->fetch($config);
// The model might have been deleted meanwhile.
if (!$model) {
continue;
}
$formatModelLabelEvent = new FormatModelLabelEvent($environment, $model);
$eventDispatcher->dispatch(DcGeneralEvents::FORMAT_MODEL_LABEL, $formatModelLabelEvent);
$label = $formatModelLabelEvent->getLabel();
$label = array_shift($label);
$label = $label['content'];
} else {
$model = $dataProvider->getEmptyModel();
$label = $environment->getTranslator()->translate('new.0', $item->getDataProviderName());
}
$options[$item->getClipboardId()] = array('item' => $item, 'model' => $model, 'label' => $label);
}
$addToUrlEvent = new AddToUrlEvent('act=clear-clipboard&original-act=' . $input->getParameter('act'));
$eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $addToUrlEvent);
$clearUrl = $addToUrlEvent->getUrl();
$addToUrlEvent = new AddToUrlEvent('clipboard-item=%id%&act=clear-clipboard&original-act=' . $input->getParameter('act'));
$eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $addToUrlEvent);
$clearItemUrl = $addToUrlEvent->getUrl();
$template = new \BackendTemplate('dcbe_general_clipboard');
$template->setData(array('environment' => $environment, 'options' => $options, 'clearUrl' => $clearUrl, 'clearItemUrl' => $clearItemUrl));
$event->setResponse($template->parse());
}
示例6: sendNewsletter
/**
* Compile the newsletter and send it
* @param object
* @param object
* @param array
* @param string
* @param string
* @param string
* @return string
*/
protected function sendNewsletter(Email $objEmail, Database_Result $objNewsletter, $arrRecipient, $text, $html, $css)
{
// Prepare text content
$objEmail->text = $this->parseSimpleTokens($text, $arrRecipient);
// Add HTML content
if (!$objNewsletter->sendText) {
// Get the mail template
$objTemplate = new BackendTemplate(strlen($objNewsletter->template) ? $objNewsletter->template : 'mail_default');
$objTemplate->setData($objNewsletter->row());
$objTemplate->title = $objNewsletter->subject;
$objTemplate->body = $this->parseSimpleTokens($html, $arrRecipient);
$objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$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 (count($objEmail->failures)) {
$_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
}
}
示例7: 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 = \String::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 = \String::parseSimpleTokens($html, $arrRecipient);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->css = $css;
// Backwards compatibility
$objTemplate->recipient = $arrRecipient['email'];
// 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);
}
}
}
示例8: sendNewsletter
/**
* Compile the newsletter and send it
* @param \Email
* @param \Database_Result
* @param array
* @param string
* @param string
* @param string
* @return string
*/
protected function sendNewsletter(\Email $objEmail, \Database_Result $objNewsletter, $arrRecipient, $text, $html, $css = null)
{
// Prepare the text content
$objEmail->text = \String::parseSimpleTokens($text, $arrRecipient);
// Add the HTML content
if (!$objNewsletter->sendText) {
// Default template
if ($objNewsletter->template == '') {
$objNewsletter->template = 'mail_default';
}
// Load the mail template
$objTemplate = new \BackendTemplate($objNewsletter->template);
$objTemplate->setData($objNewsletter->row());
$objTemplate->title = $objNewsletter->subject;
$objTemplate->body = \String::parseSimpleTokens($html, $arrRecipient);
$objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$objTemplate->css = $css;
// Backwards compatibility
// 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'];
}
}
示例9: parseTemplate
protected static function parseTemplate($strTemplate, $objEntityTemplate, $strTargetFile, array $arrData = array())
{
if (!$strTemplate) {
return;
}
$objTemplate = new \BackendTemplate($strTemplate);
$objTemplate->setData($arrData + $objEntityTemplate->row());
$strResult = $objTemplate->parse();
if ($strResult) {
new \Folder(Files::getPathWithoutFilename($strTargetFile));
if (file_put_contents(TL_ROOT . '/' . $strTargetFile, '<?php' . "\n\n" . $strResult) !== false) {
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['MSC']['entity_generator']['fileSuccessfullyGenerated'], $strTargetFile));
}
}
}
示例10: setData
/**
* {@inheritDoc}
*/
public function setData($data)
{
parent::setData($data);
return $this;
}
示例11: sendNewsletter
/**
* Compile the newsletter and send it
* @param \Email
* @param \Database\Result
* @param array
* @param string
* @param string
* @param string
* @return string
*/
protected function sendNewsletter(\Email $objEmail, \Database\Result $objNewsletter, $arrRecipient, $text, $body, $css = null)
{
// Prepare the text content
$text = \String::parseSimpleTokens($text, $arrRecipient);
// add piwik campaign links
$text = $this->addPiwikCampaignText($text, $objNewsletter->hoja_piwik_campaign);
$objEmail->text = $text;
// Add the HTML content
if (!$objNewsletter->sendText) {
// Default template
if ($objNewsletter->template == '') {
$objNewsletter->template = 'mail_default';
}
// Load the mail template
$objTemplate = new \BackendTemplate($objNewsletter->template);
$objTemplate->setData($objNewsletter->row());
$objTemplate->title = $objNewsletter->subject;
$objTemplate->body = $body;
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->css = $css;
// Backwards compatibility
$this->addCssToTemplate($objTemplate);
$objTemplate->recipient = $arrRecipient['email'];
// Parse template
$html = $objTemplate->parse();
$html = $this->convertRelativeUrls($html);
$html = $this->replaceInsertTags($html);
// $html = $this->prepareLinkTracking($html, $objNewsletter->id, $arrRecipient['email'], $arrRecipient['extra'] ?: '');
$html = $this->parseSimpleTokens($html, $arrRecipient);
// add piwik campaign links
$html = $this->addPiwikCampaignHtml($html, $objNewsletter->hoja_piwik_campaign);
// Append to mail object
$objEmail->html = $html;
$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);
}
}
}
示例12: generate
/**
* Generate the collection using a template. Useful for PDF output
* @param string
* @param boolean
* @return string
*/
public function generate($strTemplate = null, $blnResetConfig = true)
{
if ($strTemplate) {
$this->strTemplate = $strTemplate;
}
$this->import('Isotope');
// Set global config to this collection (if available)
if ($this->config_id > 0) {
$this->Isotope->overrideConfig($this->config_id);
}
$objTemplate = new BackendTemplate($this->strTemplate);
$objTemplate->setData($this->arrData);
$objTemplate->logoImage = '';
if ($this->Isotope->Config->invoiceLogo != '' && is_file(TL_ROOT . '/' . $this->Isotope->Config->invoiceLogo)) {
$objTemplate->logoImage = '<img src="' . $this->Environment->base . '/' . $this->Isotope->Config->invoiceLogo . '" alt="" />';
}
$objTemplate->invoiceTitle = $GLOBALS['TL_LANG']['MSC']['iso_invoice_title'] . ' ' . $this->order_id . ' – ' . date($GLOBALS['TL_CONFIG']['datimFormat'], $this->date);
$arrItems = array();
$arrProducts = $this->getProducts();
foreach ($arrProducts as $objProduct) {
$arrItems[] = array('raw' => $objProduct->getData(), 'product_options' => $objProduct->getOptions(), 'name' => $objProduct->name, 'quantity' => $objProduct->quantity_requested, 'price' => $objProduct->formatted_price, 'total' => $objProduct->formatted_total_price, 'tax_id' => $objProduct->tax_id);
}
$objTemplate->config = $this->Isotope->Config->getData();
$objTemplate->info = deserialize($this->checkout_info);
$objTemplate->items = $arrItems;
$objTemplate->raw = $this->arrData;
$objTemplate->date = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $this->date);
$objTemplate->time = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $this->date);
$objTemplate->datim = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $this->date);
$objTemplate->datimLabel = $GLOBALS['TL_LANG']['MSC']['datimLabel'];
$objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->subTotal);
$objTemplate->grandTotal = $this->Isotope->formatPriceWithCurrency($this->grandTotal);
$objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
$objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
$objTemplate->surcharges = IsotopeFrontend::formatSurcharges($this->getSurcharges());
$objTemplate->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_address'];
$objTemplate->billing_address = $this->Isotope->generateAddressString(deserialize($this->billing_address), $this->Isotope->Config->billing_fields);
if (strlen($this->shipping_method)) {
$arrShippingAddress = deserialize($this->shipping_address);
if (!is_array($arrShippingAddress) || $arrShippingAddress['id'] == -1) {
$objTemplate->has_shipping = false;
$objTemplate->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_shipping_address'];
} else {
$objTemplate->has_shipping = true;
$objTemplate->shipping_label = $GLOBALS['TL_LANG']['ISO']['shipping_address'];
$objTemplate->shipping_address = $this->Isotope->generateAddressString($arrShippingAddress, $this->Isotope->Config->shipping_fields);
}
}
$strArticle = $this->Isotope->replaceInsertTags($objTemplate->parse());
$strArticle = html_entity_decode($strArticle, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']);
$strArticle = $this->Isotope->convertRelativeUrls($strArticle, '', true);
// Remove form elements and JavaScript links
$arrSearch = array('@<form.*</form>@Us', '@<a [^>]*href="[^"]*javascript:[^>]+>.*</a>@Us');
$strArticle = preg_replace($arrSearch, '', $strArticle);
// Handle line breaks in preformatted text
$strArticle = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strArticle);
// Default PDF export using TCPDF
$arrSearch = array('@<span style="text-decoration: ?underline;?">(.*)</span>@Us', '@(<img[^>]+>)@', '@(<div[^>]+block[^>]+>)@', '@[\\n\\r\\t]+@', '@<br /><div class="mod_article@', '@href="([^"]+)(pdf=[0-9]*(&|&)?)([^"]*)"@');
$arrReplace = array('<u>$1</u>', '<br />$1', '<br />$1', ' ', '<div class="mod_article', 'href="$1$4"');
$strArticle = preg_replace($arrSearch, $arrReplace, $strArticle);
// Set config back to default
if ($blnResetConfig) {
$this->Isotope->resetConfig(true);
}
return $strArticle;
}
示例13: exportTerms
public function exportTerms()
{
$objGlossar = new \BackendTemplate('be_glossar_export');
$objGlossar->setData(array('lickey' => true, 'headline' => 'Export', 'glossarMessage' => '', 'glossarSubmit' => 'Export', 'glossarLabel' => 'Format wählen', 'glossarHelp' => 'Bitte wählen Sie das Format aus, mit der der Exporter Ihre Einträge exportieren soll.', 'action' => ampersand(\Environment::get('request'), true)));
$db =& $this->Database;
$ext = $db->prepare("select * from `tl_repository_installs` where `extension`='SWGlossar'")->execute();
if ($ext->lickey == false || $ext->lickey == 'free2use') {
$objGlossar->lickey = false;
}
return $objGlossar->parse();
}