public function countdown_box::render in Countdown 7.2
Implementation of boxes_box::render().
Overrides boxes_box::render
File
- plugins/
countdown_box.inc, line 146
Class
- countdown_box
- Countdown box.
Code
public function render() {
// Get the countdown plugin to add the countdown.
$countdown_plugin = ctools_get_plugins('countdown', 'countdown', $this->options['countdown_plugin']);
// Load the plugin file. It won't be loaded, as we're letting CTools cache
// plugin definitions.
// TODO: is there a CTools API function for this?
// Note that this sets the $plugin variable from the top of the plugin .inc
// file (hence the reason we're using $countdown_plugin, so it's not
// clobbered).
include_once $countdown_plugin['path'] . '/' . $countdown_plugin['name'] . '.inc';
$plugin_callback = $countdown_plugin['callback'];
// Build the options for the countdown plugin.
$countdown_options = $this->options;
// Build an ID from the block delta so that countdown plugins can have a
// unique CSS ID.
$countdown_options['css_id'] = $this->delta;
// Add the target date timezone and unix timestamp.
$date = new dateObject($countdown_options['countdown_target'], new DateTimeZone('UTC'));
// Convert the date to the site timezone.
$date
->setTimezone(date_default_timezone_object());
$countdown_options['countdown_target_timestamp'] = $date
->getTimestamp();
$countdown_options['countdown_target_offset'] = $date
->getOffset() / (60 * 60);
// Process and sanitize the event description and name.
$countdown_options['event_description'] = format_string(check_plain($countdown_options['event_description']), array(
'@event_name' => $countdown_options['event_name'],
));
$countdown_options['event_name'] = check_plain($countdown_options['event_name']);
$title = isset($this->title) ? $this->title : NULL;
$content = $plugin_callback($countdown_plugin, $countdown_options);
return array(
'delta' => $this->delta,
// Crucial.
'title' => $title,
'subject' => $title,
'content' => $content,
);
}