ILIAS  release_8 Revision v8.24
class.ilMiniCalendarGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
31{
32 public const PRESENTATION_CALENDAR = 1;
33
34 protected ilDate $seed;
38 protected ilLanguage $lng;
39 protected ilObjUser $user;
40 protected object $parentobject;
41
42 public function __construct(ilDate $seed, object $a_par_obj)
43 {
44 global $DIC;
45
46 $ilUser = $DIC['ilUser'];
47 $lng = $DIC['lng'];
48
49 $this->user = $DIC->user();
50 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
51 $this->ctrl = $DIC->ctrl();
52 $this->lng = $lng;
53 $this->lng->loadLanguageModule('dateplaner');
54 $this->seed = $seed;
55 $this->setParentObject($a_par_obj);
56 }
57
58 public function setParentObject(object $a_parentobject): void
59 {
60 $this->parentobject = $a_parentobject;
61 }
62
63 public function getParentObject(): object
64 {
66 }
67
71 public function getHTML(): string
72 {
73 $ftpl = new ilTemplate(
74 "tpl.calendar_block_frame.html",
75 true,
76 true,
77 "Services/Calendar"
78 );
79
80 $tpl = new ilTemplate(
81 "tpl.calendar_block.html",
82 true,
83 true,
84 "Services/Calendar"
85 );
86 $this->addMiniMonth($tpl);
87
88 $ftpl->setVariable("BLOCK_TITLE", $this->lng->txt("calendar"));
89 $ftpl->setVariable("CONTENT", $tpl->get());
90 return $ftpl->get();
91 }
92
97 public function addMiniMonth(ilTemplate $a_tpl): void
98 {
99 // weekdays
100 $a_tpl->setCurrentBlock('month_header_col');
101 $a_tpl->setVariable('TXT_WEEKDAY', $this->lng->txt("cal_week_abbrev"));
102 $a_tpl->parseCurrentBlock();
103 for ($i = $this->user_settings->getWeekStart(); $i < (7 + $this->user_settings->getWeekStart()); $i++) {
104 $a_tpl->setCurrentBlock('month_header_col');
105 $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
106 $a_tpl->parseCurrentBlock();
107 }
108
109 $scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
110 $scheduler->calculate();
111
112 $counter = 0;
114 (int) $this->seed->get(IL_CAL_FKT_DATE, 'm'),
115 (int) $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
116 $this->user_settings->getWeekStart()
117 )->get() as $date) {
118 $counter++;
119 //$this->showEvents($date);
120
121 $a_tpl->setCurrentBlock('month_col');
122
123 if (count($scheduler->getByDay($date, $this->user->getTimeZone()))) {
124 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
125 #$a_tpl->setVariable('TD_CLASS','calminiapp');
126 }
127
128 if (ilCalendarUtil::_isToday($date)) {
129 $a_tpl->setVariable('TD_CLASS', 'calminitoday');
130 } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
131 $a_tpl->setVariable('TD_CLASS', 'calministd');
132 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
133 $a_tpl->setVariable('TD_CLASS', 'calminiprev');
134 } else {
135 $a_tpl->setVariable('TD_CLASS', 'calmininext');
136 }
137
138 $day = $date->get(IL_CAL_FKT_DATE, 'j');
139 $month = $date->get(IL_CAL_FKT_DATE, 'n');
140
141 $month_day = $day;
142
143 $this->ctrl->clearParametersByClass('ilcalendardaygui');
144 $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
145 $a_tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
146 $this->ctrl->clearParametersByClass('ilcalendardaygui');
147
148 $a_tpl->setVariable('MONTH_DAY', $month_day);
149 $a_tpl->parseCurrentBlock();
150
151 if ($counter and !($counter % 7)) {
152 $a_tpl->setCurrentBlock('week');
153 $a_tpl->setVariable(
154 'WEEK',
155 $date->get(IL_CAL_FKT_DATE, 'W')
156 );
157 $a_tpl->parseCurrentBlock();
158
159 $a_tpl->setCurrentBlock('month_row');
160 $this->ctrl->clearParametersByClass('ilcalendarweekgui');
161 $this->ctrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
162 $this->ctrl->clearParametersByClass('ilcalendarweekgui');
163 $a_tpl->setVariable('TD_CLASS', 'calminiweek');
164 $a_tpl->parseCurrentBlock();
165 }
166 }
167 $a_tpl->setCurrentBlock('mini_month');
168 //$a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
169 $a_tpl->setVariable(
170 'TXT_MONTH',
171 $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
172 ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')
173 );
174 $myseed = clone($this->seed);
175 $this->ctrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
176 $a_tpl->setVariable('OPEN_MONTH_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
177
178 $myseed->increment(ilDateTime::MONTH, -1);
179 $this->ctrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
180
181 $a_tpl->setVariable(
182 'PREV_MONTH',
183 $this->ctrl->getLinkTarget($this->getParentObject(), "")
184 );
185
186 $myseed->increment(ilDateTime::MONTH, 2);
187 $this->ctrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
188 $a_tpl->setVariable(
189 'NEXT_MONTH',
190 $this->ctrl->getLinkTarget($this->getParentObject(), "")
191 );
192
193 $this->ctrl->setParameter($this->getParentObject(), 'seed', "");
194 $a_tpl->parseCurrentBlock();
195 }
196}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
const IL_CAL_DATE
const IL_CAL_MONTH
const IL_CAL_FKT_DATE
Represents a list of calendar appointments (including recurring events) for a specific user in a give...
static _getInstanceByUserId(int $a_user_id)
static _numericDayToString(int $a_day, bool $a_long=true)
static _buildMonthDayList(int $a_month, int $a_year, int $weekstart)
Build a month day list.
static _isToday(ilDateTime $date)
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Class for single dates.
language handling
ilGlobalTemplateInterface $tpl
__construct(ilDate $seed, object $a_par_obj)
setParentObject(object $a_parentobject)
addMiniMonth(ilTemplate $a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab.
getHTML()
Get HTML for calendar.
ilCalendarUserSettings $user_settings
User class.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
$i
Definition: metadata.php:41