ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMiniCalendarGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
25
34{
36
37 protected $seed;
38 protected $mode = null;
39 protected $user_settings = null;
40 protected $tpl = null;
41 protected $lng;
42
50 public function __construct(ilDate $seed, $a_par_obj)
51 {
52 global $DIC;
53
54 $ilUser = $DIC['ilUser'];
55 $lng = $DIC['lng'];
56
57 $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
58 $this->lng = $lng;
59 $this->lng->loadLanguageModule('dateplaner');
60 $this->seed = $seed;
61 $this->setParentObject($a_par_obj);
62 }
63
69 public function setParentObject($a_parentobject)
70 {
71 $this->parentobject = $a_parentobject;
72 }
73
79 public function getParentObject()
80 {
81 return $this->parentobject;
82 }
83
87 public function getHTML()
88 {
89 global $DIC;
90
91 $lng = $DIC['lng'];
92
93 $ftpl = new ilTemplate(
94 "tpl.calendar_block_frame.html",
95 true,
96 true,
97 "Services/Calendar"
98 );
99
100 $tpl = new ilTemplate(
101 "tpl.calendar_block.html",
102 true,
103 true,
104 "Services/Calendar"
105 );
106 $this->addMiniMonth($tpl);
107
108 $ftpl->setVariable("BLOCK_TITLE", $lng->txt("calendar"));
109 $ftpl->setVariable("CONTENT", $tpl->get());
110 return $ftpl->get();
111 }
112
117 public function addMiniMonth($a_tpl)
118 {
119 global $DIC;
120
121 $ilCtrl = $DIC['ilCtrl'];
122 $lng = $DIC['lng'];
123 $ilUser = $DIC['ilUser'];
124
125 // weekdays
126 include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
127 $a_tpl->setCurrentBlock('month_header_col');
128 $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
129 $a_tpl->parseCurrentBlock();
130 for ($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++) {
131 $a_tpl->setCurrentBlock('month_header_col');
132 $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
133 $a_tpl->parseCurrentBlock();
134 }
135
136 include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
137 $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
138 $this->scheduler->calculate();
139
140 $counter = 0;
142 $this->seed->get(IL_CAL_FKT_DATE, 'm'),
143 $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
144 $this->user_settings->getWeekStart()
145 )->get() as $date) {
146 $counter++;
147 //$this->showEvents($date);
148
149
150 $a_tpl->setCurrentBlock('month_col');
151
152 if (count($this->scheduler->getByDay($date, $ilUser->getTimeZone()))) {
153 $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
154 #$a_tpl->setVariable('TD_CLASS','calminiapp');
155 }
156
157 include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
158 if (ilCalendarUtil::_isToday($date)) {
159 $a_tpl->setVariable('TD_CLASS', 'calminitoday');
160 }
161 #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
162 #{
163 # $a_tpl->setVariable('TD_CLASS','calmininow');
164 #}
165 elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
166 $a_tpl->setVariable('TD_CLASS', 'calministd');
167 } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
168 $a_tpl->setVariable('TD_CLASS', 'calminiprev');
169 } else {
170 $a_tpl->setVariable('TD_CLASS', 'calmininext');
171 }
172
173 $day = $date->get(IL_CAL_FKT_DATE, 'j');
174 $month = $date->get(IL_CAL_FKT_DATE, 'n');
175
176 $month_day = $day;
177
178 $ilCtrl->clearParametersByClass('ilcalendardaygui');
179 $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
180 $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
181 $ilCtrl->clearParametersByClass('ilcalendardaygui');
182
183 $a_tpl->setVariable('MONTH_DAY', $month_day);
184 $a_tpl->parseCurrentBlock();
185
186 if ($counter and !($counter % 7)) {
187 $a_tpl->setCurrentBlock('week');
188 $a_tpl->setVariable(
189 'WEEK',
190 $date->get(IL_CAL_FKT_DATE, 'W')
191 );
192 $a_tpl->parseCurrentBlock();
193
194 $a_tpl->setCurrentBlock('month_row');
195 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
196 $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
197 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
198 $a_tpl->setVariable('TD_CLASS', 'calminiweek');
199 $a_tpl->parseCurrentBlock();
200 }
201 }
202 $a_tpl->setCurrentBlock('mini_month');
203 //$a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
204 $a_tpl->setVariable(
205 'TXT_MONTH',
206 $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
207 ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')
208 );
209 $myseed = clone($this->seed);
210 $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
211 $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
212
213 $myseed->increment(ilDateTime::MONTH, -1);
214 $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
215
216 //$a_tpl->setVariable('BL_TYPE', $this->getBlockType());
217 //$a_tpl->setVariable('BL_ID', $this->getBlockId());
218
219 $a_tpl->setVariable(
220 'PREV_MONTH',
221 $ilCtrl->getLinkTarget($this->getParentObject(), "")
222 );
223
224 $myseed->increment(ilDateTime::MONTH, 2);
225 $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
226 $a_tpl->setVariable(
227 'NEXT_MONTH',
228 $ilCtrl->getLinkTarget($this->getParentObject(), "")
229 );
230
231 $ilCtrl->setParameter($this->getParentObject(), 'seed', "");
232 $a_tpl->parseCurrentBlock();
233 }
234}
An exception for terminatinating execution or to throw for unit testing.
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($a_user_id)
get singleton instance
static _isToday($date)
check if a date is today
static _numericDayToString($a_day, $a_long=true)
get
static _buildMonthDayList($a_month, $a_year, $weekstart)
Build a month day list.
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Class for single dates.
addMiniMonth($a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab.
getParentObject()
Get Parent GUI object.
__construct(ilDate $seed, $a_par_obj)
Constructor.
getHTML()
Get HTML for calendar.
setParentObject($a_parentobject)
Set Parent GUI object.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
$i
Definition: metadata.php:24