public string
render
(?int $value = null, ?int $row = null, array $options = [], mixed $publishUp = null, mixed $publishDown = null)
/**
* Render action button by item value.
*
* @param integer|null $value Current value of this item.
* @param integer|null $row The row number of this item.
* @param array $options The options to override group options.
* @param string|Date $publishUp The date which item publish up.
* @param string|Date $publishDown The date which item publish down.
*
* @return string Rendered HTML.
*
* @since 4.0.0
*/
public function render(?int $value = null, ?int $row = null, array $options = [], $publishUp = null, $publishDown = null) : string
{
if ($publishUp || $publishDown) {
$bakState = $this->getState($value);
$default = $this->getState($value) ?? $this->unknownState;
$nullDate = Factory::getDbo()->getNullDate();
$nowDate = Factory::getDate()->toUnix();
$tz = Factory::getUser()->getTimezone();
$publishUp = $publishUp !== null && $publishUp !== $nullDate ? Factory::getDate($publishUp, 'UTC')->setTimezone($tz) : false;
$publishDown = $publishDown !== null && $publishDown !== $nullDate ? Factory::getDate($publishDown, 'UTC')->setTimezone($tz) : false;
// Add tips and special titles
// Create special titles for published items
if ($value === 1) {
// Create tip text, only we have publish up or down settings
$tips = array();
if ($publishUp) {
$tips[] = Text::sprintf('JLIB_HTML_PUBLISHED_START', HTMLHelper::_('date', $publishUp, Text::_('DATE_FORMAT_LC5'), 'UTC'));
$tips[] = Text::_('JLIB_HTML_PUBLISHED_UNPUBLISH');
}
if ($publishDown) {
$tips[] = Text::sprintf('JLIB_HTML_PUBLISHED_FINISHED', HTMLHelper::_('date', $publishDown, Text::_('DATE_FORMAT_LC5'), 'UTC'));
}
$tip = empty($tips) ? false : implode('<br>', $tips);
$default['title'] = $tip;
$options['tip_title'] = Text::_('JLIB_HTML_PUBLISHED_ITEM');
if ($publishUp && $nowDate < $publishUp->toUnix()) {
$options['tip_title'] = Text::_('JLIB_HTML_PUBLISHED_PENDING_ITEM');
$default['icon'] = 'pending';
}
if ($publishDown && $nowDate > $publishDown->toUnix()) {
$options['tip_title'] = Text::_('JLIB_HTML_PUBLISHED_EXPIRED_ITEM');
$default['icon'] = 'expired';
}
}
$this->states[$value] = $default;
$html = parent::render($value, $row, $options);
$this->states[$value] = $bakState;
return $html;
}
return parent::render($value, $row, $options);
}