public function testGetDaysCaption()
 {
     $this->assertEquals('Tuesday', Weekdays::getDaysCaption(1));
     $this->assertEquals('Tue.', Weekdays::getDaysCaption(1, true));
     $this->assertEquals('Monday, Wednesday, Friday', Weekdays::getDaysCaption(array(0, 2, 4)));
     $this->assertEquals('Mon., Wed., Fri.', Weekdays::getDaysCaption(array(0, 2, 4), true));
     $this->assertEquals('Monday - Friday', Weekdays::getDaysCaption(range(0, 4)));
     $this->assertEquals('Mon. - Fri.', Weekdays::getDaysCaption(range(0, 4), true));
     $this->assertEquals('Monday, Tuesday, Wednesday, Friday', Weekdays::getDaysCaption(array(0, 1, 2, 4)));
     $this->assertEquals('Mon., Tue., Wed., Fri.', Weekdays::getDaysCaption(array(0, 1, 2, 4), true));
     $this->assertEquals('Monday - Friday', Weekdays::getDaysCaption(array(2, 0, 4, 1, 3)));
     $this->assertEquals('Monday, Wednesday, Friday', Weekdays::getDaysCaption('0,2,4'));
     $this->assertEquals('Monday - Friday', Weekdays::getDaysCaption('0,1,2,3,4'));
     $this->assertEquals('Monday, Tuesday, Wednesday, Friday', Weekdays::getDaysCaption('0,1,2,4'));
     $this->assertEquals('Monday - Friday', Weekdays::getDaysCaption('2,0,4,1,3'));
     $this->assertEquals('Monday - Friday', Weekdays::getDaysCaption(' 2 ,0    , 4 ,  1 , 3 '));
 }
Example #2
0
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     $setId = $attributes['set_id'];
     if ($setId === null or !is_numeric($setId) or $setId <= 0) {
         return;
     }
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         return;
     }
     $isOpen = $set->isOpen();
     $nextPeriod = $set->getNextOpenPeriod();
     if ($attributes['show_next'] and $nextPeriod instanceof Period) {
         $attributes['next_period'] = $nextPeriod;
         $attributes['next_string'] = sprintf($attributes['next_format'], $nextPeriod->getTimeStart()->format($attributes['date_format']), Weekdays::getWeekday($nextPeriod->getWeekday())->getName(), $nextPeriod->getTimeStart()->format($attributes['time_format']), $nextPeriod->getTimeEnd()->format($attributes['time_format']));
     }
     $attributes['is_open'] = $isOpen;
     $attributes['classes'] .= $isOpen ? $attributes['open_class'] : $attributes['closed_class'];
     $attributes['text'] = $isOpen ? $attributes['open_text'] : $attributes['closed_text'];
     $attributes['next_period'] = $set->getNextOpenPeriod();
     echo $this->renderShortcodeTemplate($attributes);
 }
/**
 *  Opening Hours: Template: Part: MetaBox OP Set
 */
use OpeningHours\Module\OpeningHours;
use OpeningHours\Module\CustomPostType\MetaBox\OpeningHours as MetaBox;
use OpeningHours\Util\Weekdays;
MetaBox::nonceField();
?>

<div class="opening-hours">

	<table class="form-table form-opening-hours">
		<tbody>
		<?php 
foreach (Weekdays::getWeekdays() as $index => $weekday) {
    ?>
			<tr class="periods-day">
				<td class="col-name" valign="top">
					<?php 
    echo $weekday->getName();
    ?>
				</td>

				<td class="col-times" colspan="2" valign="top">
					<div class="period-container" data-day="<?php 
    echo $index;
    ?>
"
					     data-set="<?php 
    echo OpeningHours::getCurrentSet()->getId();
Example #4
0
}
OpeningHours::setCurrentSetId($set->getId());
echo '<table class="op-table op-table-overview ' . $table_classes . '" id="' . $table_id_prefix . $set->getId() . '">';
if ($show_description and $set->getDescription()) {
    echo '<tr class="op-row op-row-description">';
    echo '<td class="op-cell ' . $cell_classes . ' ' . $cell_description_classes . '" colspan="2">';
    echo $set->getDescription();
    echo '</td>';
    echo '</tr>';
}
$periods = $compress ? $set->getPeriodsGroupedByDayCompressed() : $set->getPeriodsGroupedByDay();
foreach ($periods as $day => $d_periods) {
    $highlighted_day = ($highlight == 'day' and Dates::isToday($day)) ? $highlighted_day_class : null;
    echo '<tr class="op-row op-row-day ' . $row_classes . ' ' . $highlighted_day . '">';
    echo '<th scope="row" class="op-cell op-cell-heading ' . $cell_heading_classes . ' ' . $cell_classes . '">';
    echo Weekdays::getDaysCaption($day, $short);
    echo '</th>';
    echo '<td class="op-cell op-cell-periods ' . $cell_periods_classes . ' ' . $cell_classes . '">';
    if ($include_io) {
        $io = $set->getActiveIrregularOpeningOnWeekday($day);
        if ($io instanceof IrregularOpening) {
            Shortcode::renderIrregularOpening($io, $attributes);
            continue;
        }
    }
    if ($include_holidays) {
        $holiday = $set->getActiveHolidayOnWeekday($day);
        if ($holiday instanceof Holiday) {
            Shortcode::renderHoliday($holiday, $attributes);
            continue;
        }