/** @inheritdoc */ protected function init() { $this->setShortcodeTag('op-is-open'); $this->defaultAttributes = array('set_id' => null, 'open_text' => __('We\'re currently open.', self::TEXTDOMAIN), 'closed_text' => __('We\'re currently closed.', self::TEXTDOMAIN), 'show_next' => false, 'next_format' => __('We\'re open again on %2$s (%1$s) from %3$s to %4$s', self::TEXTDOMAIN), 'before_widget' => null, 'after_widget' => null, 'before_title' => null, 'after_title' => null, 'title' => null, 'classes' => null, 'next_period_classes' => null, 'open_class' => 'op-open', 'closed_class' => 'op-closed', 'date_format' => Dates::getDateFormat(), 'time_format' => Dates::getTimeFormat()); $this->validAttributeValues = array('show_next' => array(false, true)); $this->templatePath = 'shortcode/is-open.php'; }
/** * Renders an Irregular Opening Item for Overview table * * @param IrregularOpening $io The Irregular Opening to show * @param array $attributes The shortcode attributes */ public static function renderIrregularOpening(IrregularOpening $io, array $attributes) { $name = $io->getName(); $date = $io->getTimeStart()->format(Dates::getDateFormat()); $heading = $attributes['hide_io_date'] ? $name : sprintf('%s (%s)', $name, $date); $now = Dates::getNow(); $highlighted = ($attributes['highlight'] == 'period' and $io->getTimeStart() <= $now and $now <= $io->getTimeEnd()) ? $attributes['highlighted_period_class'] : null; echo '<span class="op-period-time irregular-opening ' . $highlighted . '">' . $heading . '</span>'; $time_start = $io->getTimeStart()->format($attributes['time_format']); $time_end = $io->getTimeEnd()->format($attributes['time_format']); $period = sprintf('%s – %s', $time_start, $time_end); echo '<span class="op-period-time ' . $highlighted . ' ' . $attributes['span_period_classes'] . '">' . $period . '</span>'; }
/** @inheritdoc */ protected function init() { $this->setShortcodeTag('op-irregular-openings'); $this->defaultAttributes = array('title' => null, 'set_id' => null, 'highlight' => false, 'before_widget' => null, 'after_widget' => null, 'before_title' => null, 'after_title' => null, 'class_io' => 'op-irregular-opening', 'class_highlighted' => 'highlighted', 'date_format' => Dates::getDateFormat(), 'time_format' => Dates::getTimeFormat()); $this->templatePath = 'shortcode/irregular-openings.php'; }
/** @inheritdoc */ protected function init() { $this->setShortcodeTag('op-holidays'); $this->defaultAttributes = array('title' => null, 'set_id' => null, 'highlight' => false, 'before_widget' => null, 'after_widget' => null, 'before_title' => null, 'after_title' => null, 'class_holiday' => 'op-holiday', 'class_highlighted' => 'highlighted', 'date_format' => Dates::getDateFormat()); $this->templatePath = 'shortcode/holidays.php'; }
public function testAttributes() { $this->assertEquals('H:i', Dates::getTimeFormat()); $this->assertEquals('d.m.Y', Dates::getDateFormat()); $this->assertEquals('Europe/Berlin', Dates::getTimezone()->getName()); }