ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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->tpl = new ilTemplate('tpl.minical.html',true,true,'Services/Calendar');
56  $this->lng = $lng;
57  $this->lng->loadLanguageModule('dateplaner');
58  $this->seed = $seed;
59  $this->setParentObject($a_par_obj);
60  }
61 
67  function setParentObject($a_parentobject)
68  {
69  $this->parentobject = $a_parentobject;
70  }
71 
77  function getParentObject()
78  {
79  return $this->parentobject;
80  }
81 
85  function getHTML()
86  {
87  global $lng;
88 
89  $ftpl = new ilTemplate("tpl.calendar_block_frame.html", true, true,
90  "Services/Calendar");
91 
92  $tpl = new ilTemplate("tpl.calendar_block.html", true, true,
93  "Services/Calendar");
94  $this->addMiniMonth($tpl);
95 
96  $ftpl->setVariable("IMG_BLOCK", ilUtil::getImagePath("icon_cals_s.png"));
97  $ftpl->setVariable("BLOCK_TITLE", $lng->txt("calendar"));
98  $ftpl->setVariable("CONTENT", $tpl->get());
99  $ftpl->setVariable("ALT_BLOCK", $lng->txt("icon")." ".$lng->txt("calendar"));
100  return $ftpl->get();
101  }
102 
107  function addMiniMonth($a_tpl)
108  {
109  global $ilCtrl, $lng,$ilUser;
110 
111  // weekdays
112  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
113  $a_tpl->setCurrentBlock('month_header_col');
114  $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
115  $a_tpl->parseCurrentBlock();
116  for($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++)
117  {
118  $a_tpl->setCurrentBlock('month_header_col');
119  $a_tpl->setVariable('TXT_WEEKDAY',ilCalendarUtil::_numericDayToString($i,false));
120  $a_tpl->parseCurrentBlock();
121  }
122 
123  include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
124  $this->scheduler = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_MONTH);
125  $this->scheduler->calculate();
126 
127  $counter = 0;
128  foreach(ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE,'m'),
129  $this->seed->get(IL_CAL_FKT_DATE,'Y'),
130  $this->user_settings->getWeekStart())->get() as $date)
131  {
132  $counter++;
133  //$this->showEvents($date);
134 
135 
136  $a_tpl->setCurrentBlock('month_col');
137 
138  if(count($this->scheduler->getByDay($date,$ilUser->getTimeZone())))
139  {
140  $a_tpl->setVariable('DAY_CLASS','calminiapp');
141  #$a_tpl->setVariable('TD_CLASS','calminiapp');
142  }
143 
144  include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
145  if(ilCalendarUtil::_isToday($date))
146  {
147  $a_tpl->setVariable('TD_CLASS','calminitoday');
148  }
149  #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
150  #{
151  # $a_tpl->setVariable('TD_CLASS','calmininow');
152  #}
153  elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_MONTH))
154  {
155  $a_tpl->setVariable('TD_CLASS','calministd');
156  }
157  elseif(ilDateTime::_before($date,$this->seed,IL_CAL_MONTH))
158  {
159  $a_tpl->setVariable('TD_CLASS','calminiprev');
160  }
161  else
162  {
163  $a_tpl->setVariable('TD_CLASS','calmininext');
164  }
165 
166  $day = $date->get(IL_CAL_FKT_DATE,'j');
167  $month = $date->get(IL_CAL_FKT_DATE,'n');
168 
169  $month_day = $day;
170 
171  $ilCtrl->clearParametersByClass('ilcalendardaygui');
172  $ilCtrl->setParameterByClass('ilcalendardaygui','seed',$date->get(IL_CAL_DATE));
173  $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui',''));
174  $ilCtrl->clearParametersByClass('ilcalendardaygui');
175 
176  $a_tpl->setVariable('MONTH_DAY',$month_day);
177  //$this->tpl->setVariable('NEW_SRC',ilUtil::getImagePath('new.png','calendar'));
178  //$this->tpl->setVariable('NEW_ALT',$this->lng->txt('cal_new_app'));
179  //$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
180  //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$date->get(IL_CAL_DATE));
181  //$this->tpl->setVariable('ADD_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','add'));
182 
183  //$this->tpl->setVariable('OPEN_SRC',ilUtil::getImagePath('open.png','calendar'));
184  $a_tpl->parseCurrentBlock();
185 
186  if($counter and !($counter % 7))
187  {
188  $a_tpl->setCurrentBlock('month_row');
189  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
190  $ilCtrl->setParameterByClass('ilcalendarweekgui','seed',$date->get(IL_CAL_DATE));
191  $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui',''));
192  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
193  $a_tpl->setVariable('TD_CLASS','calminiweek');
194  $a_tpl->setVariable('WEEK',
195  $date->get(IL_CAL_FKT_DATE,'W'));
196  $a_tpl->parseCurrentBlock();
197  }
198  }
199  $a_tpl->setCurrentBlock('mini_month');
200  $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
201  $a_tpl->setVariable('TXT_MONTH',
202  $lng->txt('month_'.$this->seed->get(IL_CAL_FKT_DATE,'m').'_long').
203  ' '.$this->seed->get(IL_CAL_FKT_DATE,'Y'));
204  $myseed = clone($this->seed);
205  $ilCtrl->setParameterByClass('ilcalendarmonthgui','seed',$myseed->get(IL_CAL_DATE));
206  $a_tpl->setVariable('OPEN_MONTH_VIEW',$ilCtrl->getLinkTargetByClass('ilcalendarmonthgui',''));
207 
208  $myseed->increment(ilDateTime::MONTH, -1);
209  $ilCtrl->setParameter($this->getParentObject(),'seed',$myseed->get(IL_CAL_DATE));
210 
211  //$a_tpl->setVariable('BL_TYPE', $this->getBlockType());
212  //$a_tpl->setVariable('BL_ID', $this->getBlockId());
213 
214  $a_tpl->setVariable('PREV_MONTH',
215  $ilCtrl->getLinkTarget($this->getParentObject(), ""));
216 
217  $myseed->increment(ilDateTime::MONTH, 2);
218  $ilCtrl->setParameter($this->getParentObject(),'seed',$myseed->get(IL_CAL_DATE));
219  $a_tpl->setVariable('NEXT_MONTH',
220  $ilCtrl->getLinkTarget($this->getParentObject(), ""));
221 
222  $ilCtrl->setParameter($this->getParentObject(), 'seed', "");
223  $a_tpl->parseCurrentBlock();
224  }
225 }
226 ?>