コード例 #1
0
ファイル: Calendar.php プロジェクト: blitzik/calendar
 public function render()
 {
     $template = $this->getTemplate();
     $template->setFile($this->getTemplateFile());
     if (isset($this->translator)) {
         $template->setTranslator($this->translator);
     }
     if (!isset($this->calendarGenerator)) {
         $this->cellFactory = new HorizontalCalendarCellFactory();
         $this->calendarGenerator = new CalendarGenerator($this->cellFactory);
     }
     $this->calendarData = $this->getCalendarData();
     $template->month = $this->month;
     $template->year = $this->year;
     $template->areSelectionsActive = $this->areSelectionsActive;
     $template->charsToShortTo = $this->numberOfDaysLabelsCharactersToTruncate;
     $template->rows = $this->cellFactory->getNumberOfRows();
     $template->cols = $this->cellFactory->getNumberOfColumns();
     $template->getCell = function ($row, $col) {
         $cellNumber = $this->cellFactory->calcNumber($row, $col);
         return $this->calendarData[$cellNumber];
     };
     $template->getMonthName = function ($monthNumber) {
         return $this->getMonthName($monthNumber);
     };
     $template->calendarBlocksTemplate = $this->calendarBlocksTemplate;
     $template->render();
 }
コード例 #2
0
 protected function generateCalendar($year, $month)
 {
     $this->cellFactory->setPeriod($year, $month);
     $calendarTable = [];
     for ($row = 0; $row < $this->cellFactory->getNumberOfRows(); $row++) {
         for ($col = 0; $col < $this->cellFactory->getNumberOfColumns(); $col++) {
             $cell = $this->cellFactory->createCell($row, $col);
             $calendarTable[$cell->getNumber()] = $cell;
         }
     }
     return $calendarTable;
 }