You are here

public static function CalendarHelper::weekHeader in Calendar 8

Formats the weekday information into a table header format.

Return value

array An array with weekday table header data.

3 calls to CalendarHelper::weekHeader()
Calendar::calendarBuildMiniMonth in src/Plugin/views/style/Calendar.php
Build one mini month.
Calendar::calendarBuildMonth in src/Plugin/views/style/Calendar.php
Build one month.
Calendar::render in src/Plugin/views/style/Calendar.php
Render the display in this style.

File

src/CalendarHelper.php, line 25

Class

CalendarHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\calendar

Code

public static function weekHeader($view) {
  $nameSize = $view->styleInfo
    ->getNameSize();
  $len = isset($nameSize) ? $view->styleInfo
    ->getNameSize() : (!empty($view->styleInfo
    ->isMini()) ? 1 : 3);
  $with_week = !empty($view->styleInfo
    ->isShowWeekNumbers());

  // Create week header.
  $untranslated_days = self::untranslatedDays();
  $full_translated_days = self::weekDaysOrdered(self::weekDays(TRUE));
  if ($len == 99) {
    $translated_days = $full_translated_days;
  }
  else {
    $translated_days = self::weekDaysOrdered(self::weekDaysAbbr(TRUE));
  }
  if ($with_week) {
    $row[] = [
      'header' => TRUE,
      'class' => 'days week',
      'data' => '',
      'header_id' => 'Week',
    ];
  }
  foreach ($untranslated_days as $delta => $day) {
    $label = $len < 3 ? mb_substr($translated_days[$delta], 0, $len) : $translated_days[$delta];
    $row[] = [
      'header' => TRUE,
      'class' => "days " . $day,
      'data' => $label,
      'header_id' => $full_translated_days[$delta],
    ];
  }
  return $row;
}