ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCalendarHeaderNavigationGUI Class Reference
+ Collaboration diagram for ilCalendarHeaderNavigationGUI:

Public Member Functions

 __construct ($cmdClass, ilDate $seed, $a_increment, $cmd='')
 Constructor. More...
 
 getHTML ()
 getHTML More...
 

Protected Member Functions

 incrementDate ($a_count)
 

Protected Attributes

 $cmdClass = null
 
 $cmd = null
 
 $seed = null
 
 $increment = ''
 
 $html
 
 $lng
 
 $tpl
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 36 of file class.ilCalendarHeaderNavigationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarHeaderNavigationGUI::__construct (   $cmdClass,
ilDate  $seed,
  $a_increment,
  $cmd = '' 
)

Constructor.

public

Parameters
objectilDate seed for navigation string type MONTH WEEK DAY

Definition at line 61 of file class.ilCalendarHeaderNavigationGUI.php.

References $cmd, $cmdClass, $DIC, $seed, ilCalendarUserSettings\_getInstanceByUserId(), and user().

62  {
63  global $DIC;
64 
65  $this->lng = $DIC->language();
66 
67  $this->ctrl = $DIC->ctrl();
68  $this->cmdClass = $cmdClass;
69  $this->seed = clone $seed;
70  $this->increment = $a_increment;
71  $this->cmd = $cmd;
72  $this->toolbar = $DIC->toolbar();
73  $this->ui = $DIC->ui();
74  $this->user = $DIC->user();
75 
76  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
77  }
global $DIC
Definition: saml.php:7
static _getInstanceByUserId($a_user_id)
get singleton instance
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilCalendarHeaderNavigationGUI::getHTML ( )

getHTML

public

Definition at line 85 of file class.ilCalendarHeaderNavigationGUI.php.

References $end, $lng, $start, $tpl, ilCalendarUtil\_buildWeekDayList(), ilCalendarUtil\_numericDayToString(), ilDateTime\_within(), ilDateTime\DAY, ilDatePresentation\formatDate(), ilDateTime\get(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_FKT_DATE, IL_CAL_UNIX, incrementDate(), ilDateTime\MONTH, ilUtil\now(), ilDatePresentation\setUseRelativeDates(), user(), and ilDateTime\WEEK.

86  {
87  $lng = $this->lng;
88  $ui = $this->ui;
89  $toolbar = $this->toolbar;
90 
91  $today = new ilDateTime(time(), IL_CAL_UNIX, $this->user->getTimeZone());
92 
93  $tpl = new ilTemplate("tpl.navigation_header.html", true, true, "Services/Calendar");
94 
95  // previous button
96  $this->incrementDate(-1);
97  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
98  $b1 = $ui->factory()->button()->standard($lng->txt("previous"), $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd));
99 
100  // today button
101  $contains_today = false;
102  $this->incrementDate(1);
104  switch ($this->increment) {
105  case ilDateTime::DAY:
106  $tpl->setVariable("TXT_TITLE", ilCalendarUtil::_numericDayToString($this->seed->get(IL_CAL_FKT_DATE, 'w')) .
107  ", " . ilDatePresentation::formatDate($this->seed));
108  if (date("Y-m-d") === $this->seed->get(IL_CAL_FKT_DATE, 'Y-m-d')) {
109  $contains_today = true;
110  }
111  break;
112 
113  case ilDateTime::WEEK:
114  $weekday_list = ilCalendarUtil::_buildWeekDayList($this->seed, $this->user_settings->getWeekStart())->get();
115  $start = current($weekday_list);
116  $end = end($weekday_list);
117  $tpl->setVariable("TXT_TITLE", $this->lng->txt('week') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'W') .
118  ", " . ilDatePresentation::formatDate($start) . " - " .
120  $il_date_now = new ilDateTime(ilUtil::now(), IL_CAL_DATETIME);
121  if (ilDate::_within($il_date_now, $start, $end)) {
122  $contains_today = true;
123  }
124  break;
125 
126  case ilDateTime::MONTH:
127  $tpl->setVariable("TXT_TITLE", $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
128  ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
129  if ($this->seed->get(IL_CAL_FKT_DATE, 'Y-m') == date("Y-m")) {
130  $contains_today = true;
131  }
132  break;
133  }
135  $this->ctrl->setParameterByClass(
136  get_class($this->cmdClass),
137  'seed',
138  $today->get(IL_CAL_DATE)
139  );
140  if ($contains_today) {
141  $b2 = $ui->factory()->button()->standard(
142  $lng->txt("today"),
143  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
144  )->withUnavailableAction();
145  } else {
146  $b2 = $ui->factory()->button()->standard(
147  $lng->txt("today"),
148  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
149  );
150  }
151 
152  // next button
153  $this->incrementDate(1);
154  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
155  $b3 = $ui->factory()->button()->standard($lng->txt("next"), $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd));
156  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', '');
157 
158  //$toolbar->addComponent($ui->factory()->viewControl()->section($b1,$b2,$b3));
159  $toolbar->addStickyItem($ui->factory()->viewControl()->section($b1, $b2, $b3));
160  $toolbar->addSeparator();
161 
162  return $tpl->get();
163  }
const IL_CAL_DATETIME
static _numericDayToString($a_day, $a_long=true)
get
static setUseRelativeDates($a_status)
set use relative dates
static _buildWeekDayList($a_day, $a_weekstart)
build week day list
const IL_CAL_UNIX
static now()
Return current timestamp in Y-m-d H:i:s format.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
$start
Definition: bench.php:8
special template class to simplify handling of ITX/PEAR
const IL_CAL_FKT_DATE
Date and time handling
get($a_format, $a_format_str='', $a_tz='')
get formatted date
const IL_CAL_DATE
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check whether an date is within a date duration given by start and end.
+ Here is the call graph for this function:

◆ incrementDate()

ilCalendarHeaderNavigationGUI::incrementDate (   $a_count)
protected

Definition at line 165 of file class.ilCalendarHeaderNavigationGUI.php.

References IL_CAL_DAY, IL_CAL_FKT_DATE, and ilDateTime\MONTH.

Referenced by getHTML().

166  {
167  switch ($this->increment) {
168  case ilDateTime::MONTH:
169 
170  $day = $this->seed->get(IL_CAL_FKT_DATE, 'j');
171  if ($day > 28) {
172  $this->seed->increment(IL_CAL_DAY, (31 - $day) * -1);
173  }
174  // no break
175  default:
176  $this->seed->increment($this->increment, $a_count);
177  break;
178  }
179  }
const IL_CAL_DAY
const IL_CAL_FKT_DATE
+ Here is the caller graph for this function:

Field Documentation

◆ $cmd

ilCalendarHeaderNavigationGUI::$cmd = null
protected

Definition at line 39 of file class.ilCalendarHeaderNavigationGUI.php.

Referenced by __construct().

◆ $cmdClass

ilCalendarHeaderNavigationGUI::$cmdClass = null
protected

Definition at line 38 of file class.ilCalendarHeaderNavigationGUI.php.

Referenced by __construct().

◆ $html

ilCalendarHeaderNavigationGUI::$html
protected

Definition at line 43 of file class.ilCalendarHeaderNavigationGUI.php.

◆ $increment

ilCalendarHeaderNavigationGUI::$increment = ''
protected

Definition at line 41 of file class.ilCalendarHeaderNavigationGUI.php.

◆ $lng

ilCalendarHeaderNavigationGUI::$lng
protected

Definition at line 48 of file class.ilCalendarHeaderNavigationGUI.php.

Referenced by getHTML().

◆ $seed

ilCalendarHeaderNavigationGUI::$seed = null
protected

Definition at line 40 of file class.ilCalendarHeaderNavigationGUI.php.

Referenced by __construct().

◆ $tpl

ilCalendarHeaderNavigationGUI::$tpl
protected

Definition at line 51 of file class.ilCalendarHeaderNavigationGUI.php.

Referenced by getHTML().


The documentation for this class was generated from the following file: