ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAsyncOutputHandler.php
Go to the documentation of this file.
1 <?php
2 require_once("./Services/UICore/classes/class.ilTemplate.php");
3 
12 {
13  const OUTPUT_MODAL = "output_modal";
14  const OUTPUT_EMPTY = "output_empty";
15 
16  protected $content;
17 
18  protected $heading;
19 
20  protected $window_properties;
21 
22  public function __construct($content = null, $heading = null, $windows_properties = array())
23  {
24  $this->content = $content;
25  $this->heading = $heading;
26 
27  $this->window_properties = $windows_properties;
28  }
29 
30 
38  public function terminate($type = self::OUTPUT_MODAL)
39  {
40  if ($type == self::OUTPUT_MODAL) {
41  $tpl = new ilTemplate('tpl.modal_content.html', false, false, 'Modules/StudyProgramme');
42  $tpl->setVariable('HEADING', $this->getHeading());
43  $tpl->setVariable('BODY', $this->getContent());
44 
45  //TODO: implement window properties
46  /*foreach($this->window_properties as $key => $value) {
47  if($value) {
48  $tpl->activeBlock($key);
49  } else {
50  $tpl->removeBlockData($key);
51  }
52  }*/
53 
54  echo $tpl->get();
55  exit();
56  } elseif ($type == self::OUTPUT_EMPTY) {
57  echo $this->getContent();
58  exit();
59  }
60  }
61 
62 
70  public static function encodeAsyncResponse(array $data = array())
71  {
72  global $DIC;
73  $ilCtrl = $DIC['ilCtrl'];
74 
75  $data['cmd'] = $ilCtrl->getCmd();
76 
77  return json_encode($data);
78  }
79 
80 
89  public static function handleAsyncOutput($normal_content, $async_content = null, $apply_to_tpl = true)
90  {
91  global $DIC;
92  $ilCtrl = $DIC['ilCtrl'];
93  $tpl = $DIC['tpl'];
94 
95  $content = ($ilCtrl->isAsynch() && $async_content != null)? $async_content : $normal_content;
96 
97  if ($ilCtrl->isAsynch()) {
98  echo $content;
99  exit();
100  } else {
101  if ($apply_to_tpl) {
102  $tpl->setContent($content);
103  } else {
104  return $content;
105  }
106  }
107  }
108 
114  public function getContent()
115  {
116  return $this->content;
117  }
118 
119 
125  public function setContent($content)
126  {
127  $this->content = $content;
128  }
129 
130 
136  public function getHeading()
137  {
138  return $this->heading;
139  }
140 
141 
147  public function setHeading($heading)
148  {
149  $this->heading = $heading;
150  }
151 
152 
158  public function getWindowProperties()
159  {
161  }
162 
163 
170  {
171  $this->window_properties = $window_properties;
172  }
173 }
__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.
$type
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
terminate($type=self::OUTPUT_MODAL)
Output content in different ways self::OUTPUT_MODAL: Output as bootstrap modal self::OUTPUT_EMPTY: On...
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.
static handleAsyncOutput($normal_content, $async_content=null, $apply_to_tpl=true)
Handles async output.
setHeading($heading)
Sets the heading of a modal-output.