function scheduler_handler_field_scheduler_countdown::render in Scheduler 6
File
- ./
scheduler_handler_field_scheduler_countdown.inc, line 91 - Implementation of scheduler_handler_scheduler_countdown field handler
Class
- scheduler_handler_field_scheduler_countdown
- Field handler to display a countdown until a scheduled action
Code
function render($values) {
$countdown_display = $this->options['countdown_display'];
$value = $values->{$this->field_alias};
if ($countdown_display == 'smart') {
if ($value > self::WEEK_SCALE) {
$countdown_display = 'weeks';
}
elseif ($value > self::DAY_SCALE) {
$countdown_display = 'days';
}
elseif ($value > self::HOUR_SCALE) {
$countdown_display = 'hours';
}
elseif ($value > self::MINUTE_SCALE) {
$countdown_display = 'minutes';
}
else {
$countdown_display = 'seconds';
}
}
$params = $this->render_params[$countdown_display];
$scaled_value = round($value / $params['scale']);
switch ($this->options['units_display']) {
case 'long':
$rendered_value = format_plural($scaled_value, '1 ' . $params['singular'], '@count ' . $params['plural']);
break;
case 'short':
$rendered_value = $scaled_value . $params['abbreviated'];
break;
case 'none':
$rendered_value = $scaled_value;
break;
}
return $rendered_value;
}