ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCalendarHeaderNavigationGUI Class Reference
+ Collaboration diagram for ilCalendarHeaderNavigationGUI:

Public Member Functions

 __construct (object $cmdClass, ilDate $seed, string $a_increment, string $cmd='')
 
 getHTML ()
 

Protected Member Functions

 incrementDate (int $a_count)
 

Protected Attributes

object $cmdClass
 
string $cmd
 
ilDate $seed
 
string $increment = ''
 
string $html
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilToolbarGUI $toolbar
 
ilObjUser $user
 
ilCalendarUserSettings $user_settings
 
ILIAS DI UIServices $ui
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

References $cmd, $cmdClass, $DIC, $seed, ilCalendarUserSettings\_getInstanceByUserId(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

42  {
43  global $DIC;
44 
45  $this->lng = $DIC->language();
46 
47  $this->ctrl = $DIC->ctrl();
48  $this->cmdClass = $cmdClass;
49  $this->seed = clone $seed;
50  $this->increment = $a_increment;
51  $this->cmd = $cmd;
52  $this->toolbar = $DIC->toolbar();
53  $this->ui = $DIC->ui();
54  $this->user = $DIC->user();
55  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId());
56  }
static _getInstanceByUserId(int $a_user_id)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilCalendarHeaderNavigationGUI::getHTML ( )

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

References ilCalendarUtil\_buildWeekDayList(), ilCalendarUtil\_numericDayToString(), ilDateTime\_within(), ILIAS\Repository\ctrl(), ilDateTime\DAY, ilDatePresentation\formatDate(), ilDateTime\get(), IL_CAL_DATE, IL_CAL_DATETIME, IL_CAL_FKT_DATE, IL_CAL_UNIX, incrementDate(), ILIAS\Repository\lng(), ilDateTime\MONTH, ilUtil\now(), ilDatePresentation\setUseRelativeDates(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), ILIAS\Repository\user(), ilDateTime\WEEK, and ILIAS\UI\Implementation\Component\Button\withEngagedState().

58  : string
59  {
60  $today = new ilDateTime(time(), IL_CAL_UNIX, $this->user->getTimeZone());
61  $tpl = new ilTemplate("tpl.navigation_header.html", true, true, "components/ILIAS/Calendar");
62 
63  // previous button
64  $contains_today = false;
65  $this->incrementDate(-1);
66  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
67  $b1 = $this->ui->factory()->button()->standard(
68  $this->lng->txt("previous"),
69  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
70  );
71 
72  // today button
73  $this->incrementDate(1);
75  switch ($this->increment) {
76  case ilDateTime::DAY:
77  $tpl->setVariable(
78  "TXT_TITLE",
79  ilCalendarUtil::_numericDayToString((int) $this->seed->get(IL_CAL_FKT_DATE, 'w')) .
80  ", " . ilDatePresentation::formatDate($this->seed)
81  );
82  if (date("Y-m-d") === $this->seed->get(IL_CAL_FKT_DATE, 'Y-m-d')) {
83  $contains_today = true;
84  }
85  break;
86 
87  case ilDateTime::WEEK:
88  $weekday_list = ilCalendarUtil::_buildWeekDayList(
89  $this->seed,
90  $this->user_settings->getWeekStart()
91  )->get();
92  $start = current($weekday_list);
93  $end = end($weekday_list);
94  $tpl->setVariable("TXT_TITLE", $this->lng->txt('week') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'W') .
95  ", " . ilDatePresentation::formatDate($start) . " - " .
97  $il_date_now = new ilDateTime(ilUtil::now(), IL_CAL_DATETIME);
98  if (ilDate::_within($il_date_now, $start, $end)) {
99  $contains_today = true;
100  }
101  break;
102 
103  case ilDateTime::MONTH:
104  $tpl->setVariable(
105  "TXT_TITLE",
106  $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') .
107  ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y')
108  );
109  if ($this->seed->get(IL_CAL_FKT_DATE, 'Y-m') == date("Y-m")) {
110  $contains_today = true;
111  }
112  break;
113  }
115  $this->ctrl->setParameterByClass(
116  get_class($this->cmdClass),
117  'seed',
118  $today->get(IL_CAL_DATE)
119  );
120  if ($contains_today) {
121  $b2 = $this->ui->factory()->button()->standard(
122  $this->lng->txt("today"),
123  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
124  )->withEngagedState(true);
125  } else {
126  $b2 = $this->ui->factory()->button()->standard(
127  $this->lng->txt("today"),
128  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
129  );
130  }
131  // next button
132  $this->incrementDate(1);
133  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
134  $b3 = $this->ui->factory()->button()->standard(
135  $this->lng->txt("next"),
136  $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd)
137  );
138  $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', '');
139  $this->toolbar->addStickyItem($this->ui->factory()->viewControl()->section($b1, $b2, $b3));
140  $this->toolbar->addSeparator();
141 
142  return $tpl->get();
143  }
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static array static setUseRelativeDates(bool $a_status)
set use relative dates
const IL_CAL_DATETIME
static _buildWeekDayList(ilDate $a_day, int $a_weekstart)
build week day list public
const IL_CAL_UNIX
static now()
Return current timestamp in Y-m-d H:i:s format.
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
const IL_CAL_FKT_DATE
const IL_CAL_DATE
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $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 ( int  $a_count)
protected

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

References IL_CAL_DAY, IL_CAL_FKT_DATE, and ilDateTime\MONTH.

Referenced by getHTML().

145  : void
146  {
147  switch ($this->increment) {
148  case ilDateTime::MONTH:
149  $day = $this->seed->get(IL_CAL_FKT_DATE, 'j');
150  if ($day > 28) {
151  $this->seed->increment(IL_CAL_DAY, (31 - $day) * -1);
152  }
153  // no break
154  default:
155  $this->seed->increment($this->increment, $a_count);
156  break;
157  }
158  }
const IL_CAL_DAY
const IL_CAL_FKT_DATE
+ Here is the caller graph for this function:

Field Documentation

◆ $cmd

string ilCalendarHeaderNavigationGUI::$cmd
protected

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

Referenced by __construct().

◆ $cmdClass

object ilCalendarHeaderNavigationGUI::$cmdClass
protected

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

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilCalendarHeaderNavigationGUI::$ctrl
protected

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

◆ $html

string ilCalendarHeaderNavigationGUI::$html
protected

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

◆ $increment

string ilCalendarHeaderNavigationGUI::$increment = ''
protected

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

◆ $lng

ilLanguage ilCalendarHeaderNavigationGUI::$lng
protected

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

◆ $seed

ilDate ilCalendarHeaderNavigationGUI::$seed
protected

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

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilCalendarHeaderNavigationGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilCalendarHeaderNavigationGUI::$tpl
protected

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

◆ $ui

ILIAS DI UIServices ilCalendarHeaderNavigationGUI::$ui
protected

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

◆ $user

ilObjUser ilCalendarHeaderNavigationGUI::$user
protected

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

◆ $user_settings

ilCalendarUserSettings ilCalendarHeaderNavigationGUI::$user_settings
protected

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


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