You are here

function cmfcCalendarV1::getYmdwMonthAsNavigationalArray in Calendar Systems 8.2

Same name and namespace in other branches
  1. 8 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  2. 5 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  3. 6.3 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  4. 6 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  5. 7.3 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  6. 7 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()
  7. 7.2 calendar/v1/calendarV1.class.inc.php \cmfcCalendarV1::getYmdwMonthAsNavigationalArray()

File

calendar/v1/calendarV1.class.inc.php, line 186

Class

cmfcCalendarV1

Code

function getYmdwMonthAsNavigationalArray($options) {
  if (empty($options['columnsHorizontal'])) {
    $options['columnsHorizontal'] = 6;
  }
  if (empty($options['columnsVertical'])) {
    $options['columnsVertical'] = 5;
  }
  if (isset($options['secondaryCalendar'])) {
    $secondaryCalendar = self::factory(array(
      'name' => $options['secondaryCalendar'],
    ));
  }
  $table = array();
  $currentMonth = $this
    ->timestampToInfoArray();
  if (is_null($options['year'])) {
    $options['year'] = $currentMonth['year'];
  }
  if (is_null($options['month'])) {
    $options['month'] = $currentMonth['month'];
  }
  if (is_null($options['day'])) {
    $options['day'] = 1;
  }
  else {
    $selectedDay = $options['day'];
  }
  $previousMonth = $this
    ->infoArrayToInfoArray(array(
    'year' => $options['year'],
    'month' => $options['month'] - 1,
    'day' => $options['day'],
  ));
  $activeMonth = $this
    ->infoArrayToInfoArray(array(
    'year' => $options['year'],
    'month' => $options['month'],
    'day' => $options['day'],
  ));
  $nextMonth = $this
    ->infoArrayToInfoArray(array(
    'year' => $options['year'],
    'month' => $options['month'] + 1,
    'day' => $options['day'],
  ));
  $table['currentMonth'] = $currentMonth;
  $table['activeMonth'] = $activeMonth;
  $table['nextMonth'] = $nextMonth;
  $table['previousMonth'] = $previousMonth;
  foreach ($this->_weeksName as $x => $weekName) {

    //for ($x=1;$x<=$options['columnsHorizontal'];$x++) {
    $table['weekDays'][$x] = array(
      'number' => $x,
      'name' => $weekName,
      'shortName' => '',
    );
  }
  $dayNumber = 1;
  $monthStarted = false;
  for ($y = 1; $y <= $options['columnsVertical']; $y++) {
    for ($x = 0; $x <= $options['columnsHorizontal']; $x++) {
      $value = array();

      //echo $activeMonth['monthFirstDayWeekday'].'-'.$x.'<br />';
      if (($x == $activeMonth['monthFirstDayWeekday'] or $y > 1 or $monthStarted == true) and $dayNumber <= $activeMonth['monthDaysNumber']) {
        $monthStarted = true;
        $value['status'] = array();
        $value['day'] = $dayNumber;
        if ($dayNumber == $selectedDay) {
          $value['status'][] = 'selected';
        }
        if ($dayNumber == $currentMonth['day'] and $currentMonth['month'] == $activeMonth['month'] and $currentMonth['year'] == $activeMonth['year']) {
          $value['status'][] = 'today';
        }
        if (in_array($x, $this->_weekDaysHoliday)) {
          $value['status'][] = 'holiday';
        }
        if (isset($secondaryCalendar)) {
          $__activeMonth = $activeMonth;
          $__activeMonth['day'] = $dayNumber;
          $value['secondaryCalendar'] = $secondaryCalendar
            ->timestampToInfoArray($this
            ->infoArrayToTimestamp($__activeMonth));
        }
        if ($y == 5 and $x == 6 and $activeMonth['monthDaysNumber'] > $dayNumber) {
          $options['columnsVertical']++;
        }
        $dayNumber++;
      }
      $table['days'][$y][$x] = $value;
    }
  }
  return $table;
}