ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAsyncOutputHandler.php
Go to the documentation of this file.
1 <?php
2 require_once("./Services/UICore/classes/class.ilTemplate.php");
3 
12  const OUTPUT_MODAL = "output_modal";
13  const OUTPUT_EMPTY = "output_empty";
14 
15  protected $content;
16 
17  protected $heading;
18 
19  protected $window_properties;
20 
21  public function __construct($content = null, $heading = null, $windows_properties = array()) {
22  $this->content = $content;
23  $this->heading = $heading;
24 
25  $this->window_properties = $windows_properties;
26  }
27 
28 
36  public function terminate($type = self::OUTPUT_MODAL) {
37  if($type == self::OUTPUT_MODAL) {
38  $tpl = new ilTemplate('tpl.modal_content.html', false, false, 'Modules/StudyProgramme');
39  $tpl->setVariable('HEADING', $this->getHeading());
40  $tpl->setVariable('BODY', $this->getContent());
41 
42  //TODO: implement window properties
43  /*foreach($this->window_properties as $key => $value) {
44  if($value) {
45  $tpl->activeBlock($key);
46  } else {
47  $tpl->removeBlockData($key);
48  }
49  }*/
50 
51  echo $tpl->get();
52  exit();
53 
54  } else if($type == self::OUTPUT_EMPTY) {
55 
56  echo $this->getContent();
57  exit();
58  }
59  }
60 
61 
69  public static function encodeAsyncResponse(array $data = array()) {
70  global $ilCtrl;
71 
72  $data['cmd'] = $ilCtrl->getCmd();
73 
74  return json_encode($data);
75  }
76 
77 
86  public static function handleAsyncOutput($normal_content, $async_content = null, $apply_to_tpl = true) {
87  global $ilCtrl, $tpl;
88 
89  $content = ($ilCtrl->isAsynch() && $async_content != null)? $async_content : $normal_content;
90 
91  if($ilCtrl->isAsynch()) {
92  echo $content;
93  exit();
94  } else {
95  if($apply_to_tpl) {
96  $tpl->setContent($content);
97  } else {
98  return $content;
99  }
100  }
101  }
102 
108  public function getContent() {
109  return $this->content;
110  }
111 
112 
118  public function setContent($content) {
119  $this->content = $content;
120  }
121 
122 
128  public function getHeading() {
129  return $this->heading;
130  }
131 
132 
138  public function setHeading($heading) {
139  $this->heading = $heading;
140  }
141 
142 
148  public function getWindowProperties() {
150  }
151 
152 
159  $this->window_properties = $window_properties;
160  }
161 
162 }
__construct($content=null, $heading=null, $windows_properties=array())
getWindowProperties()
Return all window properties.
Class ilAsyncOutputHandler Handles the output for async-requests.
getHeading()
Return the heading of a modal.
exit
Definition: login.php:54
terminate($type=self::OUTPUT_MODAL)
Output content in different ways self::OUTPUT_MODAL: Output as bootstrap modal self::OUTPUT_EMPTY: On...
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setWindowProperties($window_properties)
Set windows properties.
$data
static encodeAsyncResponse(array $data=array())
Encode data as json for async output.
setContent($content)
Sets the content of the modal output.
getContent()
Returns the content of the modal output.
special template class to simplify handling of ITX/PEAR
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
setHeading($heading)
Sets the heading of a modal-output.