예제 #1
0
 /** @inheritdoc */
 public function renderMetaBox(WP_Post $post)
 {
     OpeningHoursModule::setCurrentSetId($post->ID);
     $set = OpeningHoursModule::getCurrentSet();
     if (count($set->getHolidays()) < 1) {
         $set->getHolidays()->append(Holiday::createDummyPeriod());
     }
     $variables = array('holidays' => $set->getHolidays());
     echo $this->renderTemplate(self::TEMPLATE_PATH, $variables, 'once');
 }
 /** @inheritdoc */
 public function renderMetaBox(WP_Post $post)
 {
     OpeningHoursModule::setCurrentSetId($post->ID);
     $set = OpeningHoursModule::getCurrentSet();
     if (count($set->getIrregularOpenings()) < 1) {
         $set->getIrregularOpenings()->append(IrregularOpening::createDummy());
     }
     $variables = array('irregular_openings' => $set->getIrregularOpenings());
     echo self::renderTemplate(static::TEMPLATE_PATH, $variables, 'once');
 }
예제 #3
0
 /** @inheritdoc */
 public function renderMetaBox(WP_Post $post)
 {
     if (!OpeningHoursModule::getSets()->offsetExists($post->ID)) {
         OpeningHoursModule::getSets()->offsetSet($post->ID, new SetEntity($post->ID));
     }
     OpeningHoursModule::setCurrentSetId($post->ID);
     $set = OpeningHoursModule::getCurrentSet();
     $set->addDummyPeriods();
     $variables = array('post' => $post, 'set' => $set);
     echo static::renderTemplate(static::TEMPLATE_PATH, $variables, 'once');
 }
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     $setId = $attributes['set_id'];
     if (!is_numeric($setId)) {
         return;
     }
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         return;
     }
     $attributes['set'] = $set;
     $attributes['irregular_openings'] = $set->getIrregularOpenings();
     echo $this->renderShortcodeTemplate($attributes);
 }
예제 #5
0
 /** @inheritdoc */
 public function shortcode(array $attributes)
 {
     if (!isset($attributes['set_id']) or !is_numeric($attributes['set_id']) or $attributes['set_id'] == 0) {
         trigger_error("Set id not properly set in Opening Hours Overview shortcode");
         return;
     }
     $setId = (int) $attributes['set_id'];
     $set = OpeningHours::getSet($setId);
     if (!$set instanceof Set) {
         trigger_error(sprintf("Set with id %d does not exist", $setId));
         return;
     }
     $attributes['set'] = $set;
     echo $this->renderShortcodeTemplate($attributes);
 }
예제 #6
0
 /** Action: Render Periods Day */
 public static function renderPeriodsDay()
 {
     $day = $_POST['day'];
     $setId = $_POST['set'];
     if (!is_int($day)) {
         self::terminate('Day is not an integer');
     }
     if (!is_int($setId)) {
         self::terminate('SetId is not an integer');
     }
     $empty = $setId === 0;
     $set = OpeningHours::getInstance()->getSet($setId);
     if (!$empty and !$set instanceof Set) {
         self::terminate(sprintf('Set with id %d does not exist', $setId));
     }
     echo self::renderTemplate('ajax/op-set-periods-day.php', array('day' => $day, 'set' => $set, 'empty' => $empty), 'always');
     die;
 }
예제 #7
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);
 }
예제 #8
0
 /**
  * Checks if Period is currently open also regarding Holidays and SpecialOpenings
  *
  * @param     DateTime  $now
  * @param     Set       $set      The set in whose context to determine the opening status of this Period
  *
  * @return    bool
  */
 public function isOpen($now = null, Set $set = null)
 {
     if ($set == null) {
         $set = OpeningHours::getCurrentSet();
     }
     if ($set->isHolidayActive($now) or $set->isIrregularOpeningActive($now)) {
         return false;
     }
     return $this->isOpenStrict($now);
 }
예제 #9
0
 /** Constructor for OpeningHours module */
 protected function __construct()
 {
     $this->registerHookCallbacks();
     $this->modules = array('OpeningHours' => Module\OpeningHours::getInstance(), 'I18n' => Module\I18n::getInstance(), 'Ajax' => Module\Ajax::getInstance(), 'CustomPostType\\Set' => Module\CustomPostType\Set::getInstance(), 'Shortcode\\IsOpen' => Module\Shortcode\IsOpen::getInstance(), 'Shortcode\\Overview' => Module\Shortcode\Overview::getInstance(), 'Shortcode\\Holidays' => Module\Shortcode\Holidays::getInstance(), 'Shortcode\\IrregularOpenings' => Module\Shortcode\IrregularOpenings::getInstance());
     $this->widgets = array('OpeningHours\\Module\\Widget\\Overview', 'OpeningHours\\Module\\Widget\\IsOpen', 'OpeningHours\\Module\\Widget\\Holidays', 'OpeningHours\\Module\\Widget\\IrregularOpenings');
 }
예제 #10
0
				<td class="col-times" colspan="2" valign="top">
					<div class="period-container" data-day="<?php 
    echo $index;
    ?>
"
					     data-set="<?php 
    echo OpeningHours::getCurrentSet()->getId();
    ?>
">

						<table class="period-table">
							<tbody>

							<?php 
    foreach (OpeningHours::getCurrentSet()->getPeriodsByDay($index) as $period) {
        echo OpeningHours::renderTemplate('ajax/op-set-period.php', array('period' => $period), 'always');
    }
    ?>

							</tbody>
						</table>

					</div>
				</td>

				<td class="col-options" valign="top">
					<a class="button add-period green has-icon">
						<i class="dashicons dashicons-plus"></i>
					</a>
				</td>
			</tr>
예제 #11
0
 * @var       $row_classes        string w/ classes for row
 * @var       $cell_classes       string w/ classes for all table cells
 *
 * @var       $highlighted_day_class      string w/ class for highlighted day
 * @var       $highlighted_period_class   string w/ class for highlighted period
 * @var       $cell_heading_classes       string w/ classes for heading cells
 * @var       $cell_periods_classes       string w/ classes for cells containing periods
 * @var       $cell_description_classes   string w/ classes for description cell
 * @var       $span_period_classes        string w/ classes for period time span
 * @var       $time_format                string w/ PHP time format to format start and end time of a period with
 */
echo $before_widget;
if ($title) {
    echo $before_title . $title . $after_title;
}
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>';