ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl;
95 
96  $next_class = $ilCtrl->getNextClass($this);
97  $cmd = $ilCtrl->getCmd("getHTML");
98 
99  switch ($next_class) {
100  case 'ilcalendarappointmentgui':
101  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
102  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
103  $this->ctrl->forwardCommand($app);
104  break;
105 
106  default:
107  if ($next_class != '') {
108  // get the path and include
109  $class_path = $this->ctrl->lookupClassPath($next_class);
110  include_once($class_path);
111 
112  // check if the class implements our interface
113  $class_name = $this->ctrl->getClassForClasspath($class_path);
114  if (in_array("ilCalendarAppointmentPresentation", class_implements($class_name))) {
115  // forward command to class
116  $gui_class = new $class_name($this->appointment, $this->info_screen, $this->toolbar, null);
117  $this->ctrl->forwardCommand($gui_class);
118  }
119  }
120  break;
121  }
122  }
123 
127  public function getSeed()
128  {
129  return $this->seed;
130  }
131 
136  public function getHTML()
137  {
138  if ($this->mode == self::MODE_MODAL) {
139  return $this->getModalHTML();
140  }
141  if ($this->mode == self::MODE_LIST_ITEM) {
142  return $this->modifyListItem();
143  }
144  return "";
145  }
146 
151  public function getModalHTML()
152  {
153  include_once "./Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationFactory.php";
154 
155  $tpl = new ilTemplate('tpl.appointment_presentation.html', true, true, 'Services/Calendar');
156 
158  $info_screen->setFormAction($this->ctrl->getFormAction($this));
159 
160  #21529 create new toolbar with unique id using the entry id for this purpose
161  //$toolbar = $this->toolbar;
162  $toolbar = new ilToolbarGUI();
163  $toolbar->setId($this->appointment['event']->getEntryId());
164 
166 
167  $this->ctrl->getHTML($f);
168  $content = $info_screen->getHTML();
169 
170  //because #21529
171  $plugin_results = $this->getContentByPlugins($content, $toolbar);
172  $content = $plugin_results['content'];
173  $toolbar = $plugin_results['toolbar'];
174 
175  // show toolbar
176  $tpl->setCurrentBlock("toolbar");
177  $tpl->setVariable("TOOLBAR", $toolbar->getHTML());
178  $tpl->parseCurrentBlock();
179 
180 
181  // show infoscreen
182  $tpl->setVariable("CONTENT", $content);
183 
184  return $tpl->get();
185  }
186 
190  public function modifyListItem()
191  {
192  $li = $this->getListItem();
193  include_once "./Services/Calendar/classes/AppointmentPresentation/class.ilAppointmentPresentationFactory.php";
194  $f = ilAppointmentPresentationFactory::getInstance($this->appointment, null, null, $li);
195  $this->ctrl->getHTML($f);
196  $this->list_item = $f->getListItem();
197  }
198 
199  protected function getActivePlugins()
200  {
201  global $ilPluginAdmin;
202 
203  $res = array();
204 
205  foreach ($ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Calendar", "capm") as $plugin_name) {
206  $res[] = $ilPluginAdmin->getPluginObject(
208  "Calendar",
209  "capm",
210  $plugin_name
211  );
212  }
213 
214  return $res;
215  }
216 
217  protected function getContentByPlugins($a_content, $a_toolbar)
218  {
219  $content = $a_content;
220  $toolbar = $a_toolbar;
221  foreach ($this->getActivePlugins() as $plugin) {
222  //pass only the appointment stuff
223  $plugin->setAppointment($this->appointment['event'], new ilDateTime($this->appointment['dstart']));
224 
225  if ($new_infoscreen = $plugin->infoscreenAddContent($this->info_screen)) {
226  $this->info_screen = $new_infoscreen;
227  }
228 
229  $content = $this->info_screen->getHTML();
230  $extra_content = $plugin->addExtraContent();
231  if ($extra_content != '') {
232  $content .= $extra_content;
233  }
234 
235  if ($new_content = $plugin->replaceContent()) {
236  $content = $new_content;
237  }
238 
239  if ($new_toolbar = $plugin->toolbarAddItems($toolbar)) {
240  $toolbar = $new_toolbar;
241  }
242 
243  if ($new_toolbar = $plugin->toolbarReplaceContent()) {
244  $new_toolbar->setId($a_toolbar->getId());
245  $toolbar = $new_toolbar;
246  }
247  }
248 
249  return array(
250  'content' => $content,
251  'toolbar' => $toolbar
252  );
253  }
254 }
static _getInstance()
get singleton instance
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
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
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
Administrate calendar appointments.
const IL_COMP_SERVICE