ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarAppointmentPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 include_once './Services/Calendar/classes/class.ilCalendarSettings.php';
3 
12 {
13  const MODE_MODAL = "modal";
14  const MODE_LIST_ITEM = "list_item";
15 
16  protected $seed = null;
17  protected static $instance = null;
18  protected $settings = null;
19  protected $appointment;
20 
21  protected $mode = self::MODE_MODAL;
22 
23  protected $toolbar;
24  protected $info_screen;
25 
26 
30  protected $list_item = null;
31 
40  protected function __construct(ilDate $seed = null, $a_app)
41  {
42  global $DIC;
43  $this->lng = $DIC->language();
44  $this->ctrl = $DIC->ctrl();
45 
47 
48  $this->seed = $seed;
49  $this->appointment = $a_app;
50 
51  $this->tpl = $DIC["tpl"];
52 
53  $this->info_screen = new ilInfoScreenGUI($this);
54  $this->toolbar = new ilToolbarGUI();
55  }
56 
62  public function setListItemMode(\ILIAS\UI\Component\Item\Standard $a_val)
63  {
64  $this->list_item = $a_val;
65  $this->mode = self::MODE_LIST_ITEM;
66  }
67 
73  public function getListItem()
74  {
75  return $this->list_item;
76  }
77 
87  public static function _getInstance(ilDate $seed, $a_app)
88  {
89  return new static($seed, $a_app);
90  }
91 
92  public function executeCommand()
93  {
94  global $DIC;
95 
96  $ilCtrl = $DIC['ilCtrl'];
97 
98  $next_class = $ilCtrl->getNextClass($this);
99  $cmd = $ilCtrl->getCmd("getHTML");
100 
101  switch ($next_class) {
102  case 'ilcalendarappointmentgui':
103  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
104  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
105  $this->ctrl->forwardCommand($app);
106  break;
107 
108  default:
109  if ($next_class != '') {
110  // get the path and include
111  $class_path = $this->ctrl->lookupClassPath($next_class);
112  include_once($class_path);
113 
114  // check if the class implements our interface
115  $class_name = $this->ctrl->getClassForClasspath($class_path);
116  if (in_array("ilCalendarAppointmentPresentation", class_implements($class_name))) {
117  // forward command to class
118  $gui_class = new $class_name($this->appointment, $this->info_screen, $this->toolbar, null);
119  $this->ctrl->forwardCommand($gui_class);
120  }
121  }
122  break;
123  }
124  }
125 
129  public function getSeed()
130  {
131  return $this->seed;
132  }
133 
138  public function getHTML()
139  {
140  if ($this->mode == self::MODE_MODAL) {
141  return $this->getModalHTML();
142  }
143  if ($this->mode == self::MODE_LIST_ITEM) {
144  return $this->modifyListItem();
145  }
146  return "";
147  }
148 
153  public function getModalHTML()
154  {
155  include_once "./Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationFactory.php";
156 
157  $tpl = new ilTemplate('tpl.appointment_presentation.html', true, true, 'Services/Calendar');
158 
160  $info_screen->setFormAction($this->ctrl->getFormAction($this));
161 
162  #21529 create new toolbar with unique id using the entry id for this purpose
163  //$toolbar = $this->toolbar;
164  $toolbar = new ilToolbarGUI();
165  $toolbar->setId($this->appointment['event']->getEntryId());
166 
168 
169  $this->ctrl->getHTML($f);
170  $content = $info_screen->getHTML();
171 
172  //because #21529
173  $plugin_results = $this->getContentByPlugins($content, $toolbar);
174  $content = $plugin_results['content'];
175  $toolbar = $plugin_results['toolbar'];
176 
177  // show toolbar
178  $tpl->setCurrentBlock("toolbar");
179  $tpl->setVariable("TOOLBAR", $toolbar->getHTML());
180  $tpl->parseCurrentBlock();
181 
182 
183  // show infoscreen
184  $tpl->setVariable("CONTENT", $content);
185 
186  return $tpl->get();
187  }
188 
192  public function modifyListItem()
193  {
194  $li = $this->getListItem();
195  include_once "./Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationFactory.php";
196  $f = ilAppointmentPresentationFactory::getInstance($this->appointment, null, null, $li);
197  $this->ctrl->getHTML($f);
198  $this->list_item = $f->getListItem();
199  }
200 
201  protected function getActivePlugins()
202  {
203  global $DIC;
204 
205  $ilPluginAdmin = $DIC['ilPluginAdmin'];
206 
207  $res = array();
208 
209  foreach ($ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Calendar", "capm") as $plugin_name) {
210  $res[] = $ilPluginAdmin->getPluginObject(
212  "Calendar",
213  "capm",
214  $plugin_name
215  );
216  }
217 
218  return $res;
219  }
220 
221  protected function getContentByPlugins($a_content, $a_toolbar)
222  {
223  $content = $a_content;
224  $toolbar = $a_toolbar;
225  foreach ($this->getActivePlugins() as $plugin) {
226  //pass only the appointment stuff
227  $plugin->setAppointment($this->appointment['event'], new ilDateTime($this->appointment['dstart']));
228 
229  if ($new_infoscreen = $plugin->infoscreenAddContent($this->info_screen)) {
230  $this->info_screen = $new_infoscreen;
231  }
232 
233  $content = $this->info_screen->getHTML();
234  $extra_content = $plugin->addExtraContent();
235  if ($extra_content != '') {
236  $content .= $extra_content;
237  }
238 
239  if ($new_content = $plugin->replaceContent()) {
240  $content = $new_content;
241  }
242 
243  if ($new_toolbar = $plugin->toolbarAddItems($toolbar)) {
244  $toolbar = $new_toolbar;
245  }
246 
247  if ($new_toolbar = $plugin->toolbarReplaceContent()) {
248  $new_toolbar->setId($a_toolbar->getId());
249  $toolbar = $new_toolbar;
250  }
251  }
252 
253  return array(
254  'content' => $content,
255  'toolbar' => $toolbar
256  );
257  }
258 }
static _getInstance()
get singleton instance
settings()
Definition: settings.php:2
Class ilInfoScreenGUI.
Class Factory.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
Class BaseForm.
setListItemMode(\ILIAS\UI\Component\Item\Standard $a_val)
Set list item mode.
static _getInstance(ilDate $seed, $a_app)
get singleton instance
global $ilCtrl
Definition: ilias.php:18
$li
Definition: langwiz.php:233
Class for single dates.
foreach($_POST as $key=> $value) $res
$a_content
Definition: workflow.php:93
special template class to simplify handling of ITX/PEAR
static getInstance($a_appointment, $a_info_screen, $a_toolbar, $a_list_item)
Date and time handling
Administrate calendar appointments.
const IL_COMP_SERVICE