ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
24 include_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 $ilUser,$lng;
53 
54  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
55  $this->lng = $lng;
56  $this->lng->loadLanguageModule('dateplaner');
57  $this->seed = $seed;
58  $this->setParentObject($a_par_obj);
59  }
60 
66  public function setParentObject($a_parentobject)
67  {
68  $this->parentobject = $a_parentobject;
69  }
70 
76  public function getParentObject()
77  {
78  return $this->parentobject;
79  }
80 
84  public function getHTML()
85  {
86  global $lng;
87 
88  $ftpl = new ilTemplate(
89  "tpl.calendar_block_frame.html",
90  true,
91  true,
92  "Services/Calendar"
93  );
94 
95  $tpl = new ilTemplate(
96  "tpl.calendar_block.html",
97  true,
98  true,
99  "Services/Calendar"
100  );
101  $this->addMiniMonth($tpl);
102 
103  $ftpl->setVariable("BLOCK_TITLE", $lng->txt("calendar"));
104  $ftpl->setVariable("CONTENT", $tpl->get());
105  return $ftpl->get();
106  }
107 
112  public function addMiniMonth($a_tpl)
113  {
114  global $ilCtrl, $lng,$ilUser;
115 
116  // weekdays
117  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
118  $a_tpl->setCurrentBlock('month_header_col');
119  $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
120  $a_tpl->parseCurrentBlock();
121  for ($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++) {
122  $a_tpl->setCurrentBlock('month_header_col');
123  $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
124  $a_tpl->parseCurrentBlock();
125  }
126 
127  include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
128  $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
129  $this->scheduler->calculate();
130 
131  $counter = 0;
133  $this->seed->get(IL_CAL_FKT_DATE, 'm'),
134  $this->seed->get(IL_CAL_FKT_DATE, 'Y'),
135  $this->user_settings->getWeekStart()
136  )->get() as $date) {
137  $counter++;
138  //$this->showEvents($date);
139 
140 
141  $a_tpl->setCurrentBlock('month_col');
142 
143  if (count($this->scheduler->getByDay($date, $ilUser->getTimeZone()))) {
144  $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
145  #$a_tpl->setVariable('TD_CLASS','calminiapp');
146  }
147 
148  include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
149  if (ilCalendarUtil::_isToday($date)) {
150  $a_tpl->setVariable('TD_CLASS', 'calminitoday');
151  }
152  #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
153  #{
154  # $a_tpl->setVariable('TD_CLASS','calmininow');
155  #}
156  elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
157  $a_tpl->setVariable('TD_CLASS', 'calministd');
158  } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
159  $a_tpl->setVariable('TD_CLASS', 'calminiprev');
160  } else {
161  $a_tpl->setVariable('TD_CLASS', 'calmininext');
162  }
163 
164  $day = $date->get(IL_CAL_FKT_DATE, 'j');
165  $month = $date->get(IL_CAL_FKT_DATE, 'n');
166 
167  $month_day = $day;
168 
169  $ilCtrl->clearParametersByClass('ilcalendardaygui');
170  $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
171  $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
172  $ilCtrl->clearParametersByClass('ilcalendardaygui');
173 
174  $a_tpl->setVariable('MONTH_DAY', $month_day);
175  $a_tpl->parseCurrentBlock();
176 
177  if ($counter and !($counter % 7)) {
178  $a_tpl->setCurrentBlock('week');
179  $a_tpl->setVariable(
180  'WEEK',
181  $date->get(IL_CAL_FKT_DATE, 'W')
182  );
183  $a_tpl->parseCurrentBlock();
184 
185  $a_tpl->setCurrentBlock('month_row');
186  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
187  $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
188  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
189  $a_tpl->setVariable('TD_CLASS', 'calminiweek');
190  $a_tpl->parseCurrentBlock();
191  }
192  }
193  $a_tpl->setCurrentBlock('mini_month');
194  $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
195  $a_tpl->setVariable(
196  'TXT_MONTH',
197  $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
198  ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')
199  );
200  $myseed = clone($this->seed);
201  $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
202  $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
203 
204  $myseed->increment(ilDateTime::MONTH, -1);
205  $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
206 
207  //$a_tpl->setVariable('BL_TYPE', $this->getBlockType());
208  //$a_tpl->setVariable('BL_ID', $this->getBlockId());
209 
210  $a_tpl->setVariable(
211  'PREV_MONTH',
212  $ilCtrl->getLinkTarget($this->getParentObject(), "")
213  );
214 
215  $myseed->increment(ilDateTime::MONTH, 2);
216  $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
217  $a_tpl->setVariable(
218  'NEXT_MONTH',
219  $ilCtrl->getLinkTarget($this->getParentObject(), "")
220  );
221 
222  $ilCtrl->setParameter($this->getParentObject(), 'seed', "");
223  $a_tpl->parseCurrentBlock();
224  }
225 }
static _buildMonthDayList($a_month, $a_year, $weekstart)
Build a month day list.
__construct(ilDate $seed, $a_par_obj)
Constructor.
static _numericDayToString($a_day, $a_long=true)
get
static _getInstanceByUserId($a_user_id)
get singleton instance
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.
const IL_CAL_MONTH
global $ilCtrl
Definition: ilias.php:18
$counter
getParentObject()
Get Parent GUI object.
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
Class for single dates.
special template class to simplify handling of ITX/PEAR
const IL_CAL_FKT_DATE
$ilUser
Definition: imgupload.php:18
addMiniMonth($a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab...
setParentObject($a_parentobject)
Set Parent GUI object.
const IL_CAL_DATE
$i
Definition: disco.tpl.php:19
static _isToday($date)
check if a date is today
getHTML()
Get HTML for calendar.
Represents a list of calendar appointments (including recurring events) for a specific user in a give...