ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarHeaderNavigationGUI.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.ilCalendarUtil.php');
25 
37 {
38  protected $cmdClass = null;
39  protected $cmd = null;
40  protected $seed = null;
41  protected $increment = '';
42 
43  protected $html;
44  protected $lng;
45  protected $tpl;
46 
55  public function __construct($cmdClass,ilDate $seed,$a_increment,$cmd = '')
56  {
57  global $lng,$ilCtrl;
58 
59  $this->lng = $lng;
60 
61  $this->ctrl = $ilCtrl;
62  $this->cmdClass = $cmdClass;
63  $this->seed = clone $seed;
64  $this->increment = $a_increment;
65  $this->cmd = $cmd;
66  }
67 
74  public function getHTML()
75  {
76  global $lng;
77 
78  $this->tpl = new ilTemplate('tpl.navigation_header.html',true,true,'Services/Calendar');
79 
80  $this->incrementDate(-2);
81  $num = 0;
82  do
83  {
84  switch($this->increment)
85  {
86  case ilDateTime::DAY:
87  $this->tpl->setVariable('NAV_NAME_'.++$num,ilCalendarUtil::_numericDayToString($this->seed->get(IL_CAL_FKT_DATE,'w')));
88  break;
89 
90  case ilDateTime::WEEK:
91  $this->tpl->setVariable('NAV_NAME_'.++$num,$this->lng->txt('week').' '.$this->seed->get(IL_CAL_FKT_DATE,'W'));
92  break;
93 
94  case ilDateTime::MONTH:
95  if($num == 2)
96  {
97  $this->tpl->setVariable('NAV_NAME_'.++$num,
98  $this->lng->txt('month_'.$this->seed->get(IL_CAL_FKT_DATE,'m').'_long').
99  ' '.$this->seed->get(IL_CAL_FKT_DATE,'Y'));
100  }
101  else
102  {
103  $this->tpl->setVariable('NAV_NAME_'.++$num,$this->lng->txt('month_'.$this->seed->get(IL_CAL_FKT_DATE,'m').'_long'));
104  }
105  break;
106  }
107  $this->ctrl->setParameterByClass(get_class($this->cmdClass),'seed',$this->seed->get(IL_CAL_DATE));
108  $this->tpl->setVariable('NAV_LINK_'.$num,$this->ctrl->getLinkTarget($this->cmdClass,$this->cmd));
109  // $this->ctrl->clearParametersByClass(get_class($this->cmdClass));
110  $this->ctrl->setParameterByClass(get_class($this->cmdClass),'seed','');
111 
112  $this->incrementDate(1);
113 
114  } while($num < 6);
115 
116  // header
117  switch ($this->increment)
118  {
119  case ilDateTime::DAY:
120  $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_day_selection"));
121  $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_day_overview"));
122  break;
123 
124  case ilDateTime::WEEK:
125  $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_week_selection"));
126  $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_week_overview"));
127  break;
128 
129  case ilDateTime::MONTH:
130  $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_month_selection"));
131  $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_month_overview"));
132  break;
133  }
134  $this->tpl->setVariable('TXT_SELECTED', $lng->txt("stat_selected"));
135 
136  return $this->tpl->get();
137  }
138 
139  protected function incrementDate($a_count)
140  {
141  switch($this->increment)
142  {
143  case ilDateTime::MONTH:
144 
145  $day = $this->seed->get(IL_CAL_FKT_DATE,'j');
146  if($day > 28)
147  {
148  $this->seed->increment(IL_CAL_DAY, (31 - $day) * -1);
149  }
150  default:
151  $this->seed->increment($this->increment,$a_count);
152  break;
153  }
154  }
155 }
156 
157 ?>