ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $DIC;
71  $ilCtrl = $DIC['ilCtrl'];
72 
73  $data['cmd'] = $ilCtrl->getCmd();
74 
75  return json_encode($data);
76  }
77 
78 
87  public static function handleAsyncOutput($normal_content, $async_content = null, $apply_to_tpl = true) {
88  global $DIC;
89  $ilCtrl = $DIC['ilCtrl'];
90  $tpl = $DIC['tpl'];
91 
92  $content = ($ilCtrl->isAsynch() && $async_content != null)? $async_content : $normal_content;
93 
94  if($ilCtrl->isAsynch()) {
95  echo $content;
96  exit();
97  } else {
98  if($apply_to_tpl) {
99  $tpl->setContent($content);
100  } else {
101  return $content;
102  }
103  }
104  }
105 
111  public function getContent() {
112  return $this->content;
113  }
114 
115 
121  public function setContent($content) {
122  $this->content = $content;
123  }
124 
125 
131  public function getHeading() {
132  return $this->heading;
133  }
134 
135 
141  public function setHeading($heading) {
142  $this->heading = $heading;
143  }
144 
145 
151  public function getWindowProperties() {
153  }
154 
155 
162  $this->window_properties = $window_properties;
163  }
164 
165 }
__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.
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.
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
Create styles array
The data for the language used.
global $DIC
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
setHeading($heading)
Sets the heading of a modal-output.