public function MailChimpCampaign::buildContent in Mailchimp 7.2
Same name and namespace in other branches
- 7.5 modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc \MailChimpCampaign::buildContent()
- 7.3 modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc \MailChimpCampaign::buildContent()
- 7.4 modules/mailchimp_campaign/includes/mailchimp_campaign.entity.inc \MailChimpCampaign::buildContent()
Builds a structured array representing the entity's content.
Overrides Entity::buildContent
See also
File
- modules/
mailchimp_campaign/ mailchimp_campaign.entity.inc, line 107 - Entity API hooks for mailchimp_campaign module.
Class
- MailChimpCampaign
- Defines MailChimpCampaign entities
Code
public function buildContent($view_mode = 'full', $langcode = NULL) {
$build = parent::buildContent($view_mode, $langcode);
// prepare rendered content
$content = mailchimp_campaign_render_template($this->template);
$rendered = '';
foreach ($content as $key => $section) {
$rendered .= "<h3>{$key}</h3>" . $section;
}
// get the template name
$mc_template = mailchimp_campaign_get_templates($this->mc_data['template_id']);
$mc_template_name = isset($mc_template) ? $mc_template['name'] : '';
$fields = array(
'subject' => array(
'label' => t('Subject'),
'value' => $this->mc_data['subject'],
),
'list' => array(
'label' => t('MailChimp List'),
'value' => l($this->list['name'], 'https://admin.mailchimp.com/lists/dashboard/overview?id=' . $this->list['web_id'], array(
'attributes' => array(
'target' => '_blank',
),
)),
),
'from_email' => array(
'label' => t('From Email'),
'value' => $this->mc_data['from_email'],
),
'from_name' => array(
'label' => t('From Name'),
'value' => $this->mc_data['from_name'],
),
'template' => array(
'label' => t('Template'),
'value' => $mc_template_name,
),
'type' => array(
'label' => t('List type'),
'value' => $this->mc_data['type'],
),
'status' => array(
'label' => t('Status'),
'value' => $this->mc_data['status'],
),
'emails_sent' => array(
'label' => t('Emails sent'),
'value' => $this->mc_data['emails_sent'],
),
'send_time' => array(
'label' => t('Send time'),
'value' => $this->mc_data['send_time'],
),
'content' => array(
'label' => t('Rendered template HTML (!archive)', array(
'!archive' => l('View MailChimp archive', $this->mc_data['archive_url'], array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
'value' => $rendered,
),
);
foreach ($fields as $key => $field) {
$build[$key] = array(
'#prefix' => "<div class=\"field campaign-{$key}\"><div class=\"field-label\">{$field['label']}</div>",
'#markup' => $field['value'],
'#suffix' => '</div>',
);
}
return $build;
}